WireGuard Integration Guide
January 24, 2026 · View on GitHub
This guide aims to simplify the process of integrating WireGuard into your iOS application. I've tried to make this complex procedure easy.
Update
I tried Xcode 15 steps on Xcode 26, and it works perfectly, just match the Go version in the script file. Also, for wireguard I have used https://github.com/ut360e/wireguard-apple.git (the latest version with some fixes)
Xcode 15
Step 1: Create a New Project
Start by creating a new project in Xcode if you haven't already done so.
Step 2: Add Network Extension
- Add a new target to your project by selecting File > New > Target....
- Choose the Network Extension target type and click Next.
- Name your Network Extension, e.g.,
network-extension, and then click Finish. - When prompted to activate the scheme for the network extension, select Cancel.
Step 3: External Build System Setup
-
Add another new target by selecting File > New > Target... again. We are using this external build system for building wireguard.
-
This time, select External Build System.
-
Name this target
WireguardGoBridge. -
In the Build Tool field, enter
$(PROJECT_DIR)/script/build_wireguard_go_bridge.sh.- This script is responsible for building the WireGuard. You can find the script at
script/build_wireguard_go_bridge.sh. Add script to your project. - Modify the Go path in the script at line 38 as necessary, according to your setup. Refer to this Stack Overflow answer for guidance.
- This script is responsible for building the WireGuard. You can find the script at
Step 4: Add WireGuardKit Dependency
- To your project, add the WireGuardKit dependency by navigating to Project > Package Dependencies, then click the + button.
- Enter the URL
https://git.zx2c4.com/wireguard-appleand select the exact version1.0.15-26. - When prompted, select the
network-extensiontarget for the package.
Step 5: Configure Targets
-
For your Network Extension (NE) target:
- Go to Build Phases > Target Dependencies and add
WireguardGoBridgeas a dependency. - Under Build Phases > Link Binary with Libraries, ensure
WireguardKitandNetworkExtension.frameworkare available.
- Go to Build Phases > Target Dependencies and add
-
Ensure
WireguardKittargets thenetwork-extensionin its build phases.
Step 6: Add Configuration Extensions
In your Network Extension target, add TunnelConfiguration+wgQuickConfig and String+ArrayConversion extensions. These will help in configuring the tunnel and handling array conversions, respectively.
Dont forget to change identifier here Also edit the wireguard config here
Also please note you will need real device for testing, Network extensions don't work on simulators.
Xcode 16
Step 1: Same as above
Step 2: Same as above
Step 3: Skip this one
Step 4: Add WireGuardKit Dependency (unofficial source with fixed issue)
- To your project, add the WireGuardKit dependency by navigating to Project > Package Dependencies, then click the + button.
- Enter the URL
https://github.com/ut360e/wireguard-apple.gitand add. - When prompted, select the
network-extensiontarget for the package.
Step 5: Skip this one
Step 6: Same as above
Step 7: Add prebuilt wireguard lib.
-
In the Project Navigator, go to the NetworkExtension target → General → Frameworks & libraries.
-
Add libwg-go.a (included in the repository).
⚠️ This xcode 16 solution works perfectly for iOS, but will most likely not work for macOS, since libwg-go.a is a prebuilt WireGuard library specifically for iPhoneOS.
☕ Support My Work
If you find this project helpful, consider supporting me:
Thank you for your support! 🙏
Acknowledgements
Taken help from:
Contact
Feel free to open any issue or contact me if you face any issues.
| Platform | Link |
|---|---|
| shahzainali93@gmail.com | |
| LinkedIn Profile | |
| StackOverflow | StackOverflow Profile |
I hope this guide facilitates a smoother integration process for you. Feedback and queries are always welcome.