This project contains a static library for iOS, tvOS, and macOS.
- iOS 15.0+
- macOS 12.0+
- tvOS 17.0+
- Go 1.19 (install using Homebrew)
brew install go
AtomWireguardTunnel can be integrated into your project using Swift Package Manager (SPM).
- Open your project in Xcode.
- Select
File
>Add Package Dependencies...
- Enter the URL of the AtomWireguardTunnel repository:
https://github.com/AtomSDK/AtomWireguardTunnel
- Specify the version or branch you want to use:
- Branch Name: Documentation
- Exact Version: Documentation
- Revision: Documentation
- Up To Next Major Version: Documentation
- Up To Next Minor Version: Documentation
- Add AtomWireguardTunnel to your project.
WireGuardKit
links against the wireguard-go-bridge
library, but it cannot build it automatically due to Swift Package Manager limitations. Follow these steps to create build targets for wireguard-go-bridge
:
- In Xcode, click
File
->New
->Target
. Switch to the "Other" tab and choose "External Build System". - Type
WireGuardGoBridge<PLATFORM>
under the "Product name", replacing<PLATFORM>
with the appropriate platform name (iOS
,macOS
, ortvOS
). Ensure the Build Tool is set to$BUILD_DIR/../../SourcePackages/checkouts/AtomWireguardTunnel/Sources/AtomWireguardTunnel/build_wireguard_go_bridge.sh
. - In the "Build Settings" tab, set
SDKROOT
tomacosx
for macOS,iphoneos
for iOS, orappletvos
for tvOS. - Go to your Xcode project settings, locate your network extension target, and switch to the "Build Phases" tab.
- In the "Target Dependencies" section, add
WireGuardGoBridge<PLATFORM>
. - In the "Link with Binary Libraries" section, add
AtomWireguardTunnel
if it is not there already.
- In the "Target Dependencies" section, add
Repeat steps 2-5 for each platform if you ship your app for iOS, tvOS, and macOS.
To use AtomWireguardTunnel in your code, import it in your network extension:
import AtomWireGuardAppExtension
Update your PacketTunnelProvider
implementation:
class PacketTunnelProvider: WireGuardTunnelProvider {
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
// Add code here to start the process of connecting the tunnel.
super.startTunnel(options: options, completionHandler: completionHandler)
}
override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
// Add code here to start the process of stopping the tunnel.
super.stopTunnel(with: reason, completionHandler: completionHandler)
}
override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)?) {
// Add code here to handle the message.
super.handleAppMessage(messageData, completionHandler: completionHandler)
}
}