]> git.ipfire.org Git - thirdparty/wireguard-apple.git/blob - README.md
UI: When setting on-demand, avoid a second saveToPreferences() call
[thirdparty/wireguard-apple.git] / README.md
1 # [WireGuard](https://www.wireguard.com/) for iOS and macOS
2
3 This project contains an application for iOS and for macOS, as well as many components shared between the two of them. You may toggle between the two platforms by selecting the target from within Xcode.
4
5 ## Building
6
7 - Clone this repo:
8
9 ```
10 $ git clone https://git.zx2c4.com/wireguard-apple
11 $ cd wireguard-apple
12 ```
13
14 - Rename and populate developer team ID file:
15
16 ```
17 $ cp Sources/WireGuardApp/Config/Developer.xcconfig.template Sources/WireGuardApp/Config/Developer.xcconfig
18 $ vim Sources/WireGuardApp/Config/Developer.xcconfig
19 ```
20
21 - Install swiftlint and go 1.15:
22
23 ```
24 $ brew install swiftlint go
25 ```
26
27 - Open project in Xcode:
28
29 ```
30 $ open WireGuard.xcodeproj
31 ```
32
33 - Flip switches, press buttons, and make whirling noises until Xcode builds it.
34
35 ## WireGuardKit integration
36
37 1. Open your Xcode project and add the Swift package with the following URL:
38
39 ```
40 https://git.zx2c4.com/wireguard-apple
41 ```
42
43 2. `WireGuardKit` links against `wireguard-go-bridge` library, but it cannot build it automatically
44 due to Swift package manager limitations. So it needs a little help from a developer.
45 Please follow the instructions below to create a build target(s) for `wireguard-go-bridge`.
46
47 - In Xcode, click File -> New -> Target. Switch to "Other" tab and choose "External Build
48 System".
49 - Type in `WireGuardGoBridge<PLATFORM>` under the "Product name", replacing the `<PLATFORM>`
50 placeholder with the name of the platform. For example, when targeting macOS use `macOS`, or
51 when targeting iOS use `iOS`.
52 Make sure the build tool is set to: `/usr/bin/make` (default).
53 - In the appeared "Info" tab of a newly created target, type in the "Directory" path under
54 the "External Build Tool Configuration":
55
56 ```
57 ${BUILD_DIR%Build/*}SourcePackages/checkouts/wireguard-apple/Sources/WireGuardKitGo
58 ```
59
60 - Switch to "Build Settings" and find `SDKROOT`.
61 Type in `macosx` if you target macOS, or type in `iphoneos` if you target iOS.
62
63 3. Go to Xcode project settings and locate your network extension target and switch to
64 "Build Phases" tab.
65
66 - Locate "Dependencies" section and hit "+" to add `WireGuardGoBridge<PLATFORM>` replacing
67 the `<PLATFORM>` placeholder with the name of platform matching the network extension
68 deployment target (i.e macOS or iOS).
69
70 - Locate the "Link with binary libraries" section and hit "+" to add `WireGuardKit`.
71
72 4. In Xcode project settings, locate your main bundle app and switch to "Build Phases" tab.
73 Locate the "Link with binary libraries" section and hit "+" to add `WireGuardKit`.
74
75 5. iOS only: Locate Bitcode settings under your application target, Build settings -> Enable Bitcode,
76 change the corresponding value to "No".
77
78 Note that if you ship your app for both iOS and macOS, make sure to repeat the steps 2-4 twice,
79 once per platform.
80
81 ## MIT License
82
83 Permission is hereby granted, free of charge, to any person obtaining a copy of
84 this software and associated documentation files (the "Software"), to deal in
85 the Software without restriction, including without limitation the rights to
86 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
87 of the Software, and to permit persons to whom the Software is furnished to do
88 so, subject to the following conditions:
89
90 The above copyright notice and this permission notice shall be included in all
91 copies or substantial portions of the Software.
92
93 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
95 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
96 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
97 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
98 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
99 SOFTWARE.