WireGuard for iOS and macOS

Overview

WireGuard for iOS and macOS

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.

Building

  • Clone this repo:
$ git clone https://git.zx2c4.com/wireguard-apple
$ cd wireguard-apple
  • Rename and populate developer team ID file:
$ cp Sources/WireGuardApp/Config/Developer.xcconfig.template Sources/WireGuardApp/Config/Developer.xcconfig
$ vim Sources/WireGuardApp/Config/Developer.xcconfig
  • Install swiftlint and go 1.15:
$ brew install swiftlint go
  • Open project in Xcode:
$ open WireGuard.xcodeproj
  • Flip switches, press buttons, and make whirling noises until Xcode builds it.

WireGuardKit integration

  1. Open your Xcode project and add the Swift package with the following URL:

    https://git.zx2c4.com/wireguard-apple
    
  2. WireGuardKit links against wireguard-go-bridge library, but it cannot build it automatically due to Swift package manager limitations. So it needs a little help from a developer. Please follow the instructions below to create a build target(s) for wireguard-go-bridge.

    • In Xcode, click File -> New -> Target. Switch to "Other" tab and choose "External Build System".

    • Type in WireGuardGoBridge under the "Product name", replacing the placeholder with the name of the platform. For example, when targeting macOS use macOS, or when targeting iOS use iOS. Make sure the build tool is set to: /usr/bin/make (default).

    • In the appeared "Info" tab of a newly created target, type in the "Directory" path under the "External Build Tool Configuration":

      ${BUILD_DIR%Build/*}SourcePackages/checkouts/wireguard-apple/Sources/WireGuardKitGo
      
    • Switch to "Build Settings" and find SDKROOT. Type in macosx if you target macOS, or type in iphoneos if you target iOS.

  3. Go to Xcode project settings and locate your network extension target and switch to "Build Phases" tab.

    • Locate "Dependencies" section and hit "+" to add WireGuardGoBridge replacing the placeholder with the name of platform matching the network extension deployment target (i.e macOS or iOS).

    • Locate the "Link with binary libraries" section and hit "+" to add WireGuardKit.

  4. In Xcode project settings, locate your main bundle app and switch to "Build Phases" tab. Locate the "Link with binary libraries" section and hit "+" to add WireGuardKit.

  5. iOS only: Locate Bitcode settings under your application target, Build settings -> Enable Bitcode, change the corresponding value to "No".

Note that if you ship your app for both iOS and macOS, make sure to repeat the steps 2-4 twice, once per platform.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Bug: Fix incorrect IP address allocation size

    Bug: Fix incorrect IP address allocation size

    Documentation for withMemoryRebound(to:capacity:_:) is available below: https://developer.apple.com/documentation/swift/unsafepointer/withmemoryrebound(to:capacity:_:)

    According to it, the capacity parameter is specified as "the number of instances of T in the re-bound region," and not the total size of the rebound struct. This can lead to crashes in the extension with the following error:

    Fatal error: self must be a properly aligned pointer for types Pointee and T

    Since the subsequent line in the code only reads sizeof(in_addr) or sizeof(in6_addr) anyway, change the capacity parameter to just be a count of 1.

    opened by protonjohn 0
  • Handle dock icon click to open Tunnel Manager (`applicationShouldHandleReopen`)

    Handle dock icon click to open Tunnel Manager (`applicationShouldHandleReopen`)

    One thing that bugs me about the WireGuard macOS app is that clicking on its Dock icon does not open the Tunnel Manager window. This is non macOS-like, and limits the ability to show that window programatically via shell scripts, AppleScript, JXA, Alfred etc.

    My poor-man's kludge to automate this is to literally quit the app and re-open it, like this (JXA):

    function run(argv) {
      var WG = new Application("WireGuard");
      WG.quit();
      WG.activate();
      return;
    }
    

    ...but that's embarrassingly inefficient. I believe after looking at the code that it's because there's no applicationShouldHandleReopen() func handler.

    So this is not a full working PR, just a bit of starter code I was hoping to get refined into a working fix. I do believe the fix is small and fairly easy to implement.

    References:

    • https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428638-applicationshouldhandlereopen
    • https://developer.apple.com/forums/thread/706772?answerId=715063022#715063022
    opened by luckman212 1
  • Support Simulator and Catalyst targets

    Support Simulator and Catalyst targets

    Make Go library build correctly on iPhone Simulator and Mac Catalyst.

    Script adjustments might appear inelegant, but the generated library has worked 100% on these targets. Tested in my production app for 6+ months.

    opened by keeshux 0
  • Adding -fembed-bitcode flag to enable bitcode in XCode

    Adding -fembed-bitcode flag to enable bitcode in XCode

    "Currently libwg-go.a doesn't support bitcode in the Xcode project. It crashes with the following message:

    libwg-go.a does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

    Disabling Bitcode for the whole project is very bad for dSYMs and Crashlytics reporting, though"

    Full discussion is here

    opened by ponkin 1
  • Add DNSMatchDomains property to Interface (split DNS)

    Add DNSMatchDomains property to Interface (split DNS)

    Based on the work of Stephen Larew [email protected].

    This adds split DNS capability. MacOS and iOS don't fully support the separation of search domains and match domains so a best effort is made to implement to what the configuration intends.

    Signed-off-by: Frank Riley [email protected]

    opened by fhriley 3
Owner
WireGuard
Mirror of various WireGuard-related projects. See https://www.wireguard.com/repositories/ for official repositories.
WireGuard
Periodum-apple - iPad and macOS client for periodum.com

Periodum  iPad and macOS client for periodum.com

Umur Gedik 1 Jan 31, 2022
A library and tool for interacting with both the local and remote asset caches.

Asset Cache Tool A library and tool for interacting with both the local and remote asset caches. This is based on research I did a few years ago on th

Kenneth Endfinger 20 Dec 23, 2022
Carlos - A simple but flexible cache, written in Swift for iOS 13+ and WatchOS 6 apps.

Carlos A simple but flexible cache, written in Swift for iOS 13+ and WatchOS 6 apps. Breaking Changes Carlos 1.0.0 has been migrated from PiedPiper de

National Media & Tech 628 Dec 3, 2022
Everyone tries to implement a cache at some point in their iOS app’s lifecycle, and this is ours.

Everyone tries to implement a cache at some point in their app’s lifecycle, and this is ours. This is a library that allows people to cache NSData wit

Spotify 1.2k Dec 28, 2022
Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X

PINCache Fast, non-deadlocking parallel object cache for iOS and OS X. PINCache is a fork of TMCache re-architected to fix issues with deadlocking cau

Pinterest 2.6k Dec 28, 2022
Delightful framework for iOS to easily persist structs, images, and data

Installation • Usage • Debugging • A Word • Documentation • Apps Using Disk • License • Contribute • Questions? Disk is a powerful and simple file man

Saoud Rizwan 3k Jan 3, 2023
CachyKit - A Caching Library is written in Swift that can cache JSON, Image, Zip or AnyObject with expiry date/TTYL and force refresh.

Nice threadsafe expirable cache management that can cache any object. Supports fetching from server, single object expire date, UIImageView loading etc.

Sadman Samee 122 Dec 28, 2022
Track is a thread safe cache write by Swift. Composed of DiskCache and MemoryCache which support LRU.

Track is a thread safe cache write by Swift. Composed of DiskCache and MemoryCache which support LRU. Features Thread safe: Implement by dispatch_sema

Cheer 268 Nov 21, 2022
A caching and consistency solution for immutable models.

?? Data Rocket Data is a model management system with persistence for immutable models. Motivation Immutability has many benefits, but keeping models

Peter Livesey 652 Nov 11, 2022
🏈 Cache CocoaPods for faster rebuild and indexing Xcode project.

Motivation Working on a project with a huge amount of pods I had some troubles: - Slow and unnecessary indexing of pods targets, which implementation

Vyacheslav Khorkov 487 Jan 5, 2023
A repository for showcasing my knowledge of the Objective-C++ programming language, and continuing to learn the language.

Learning Objective-C-Plus-Plus I hardly know anything about the Objective-C++ programming language. This document will go over all of my knowledge of

Sean P. Myrick V19.1.7.2 3 Nov 8, 2022
A repository for showcasing my knowledge of the Objective-C programming language, and continuing to learn the language.

Learning Objective-C I hardly know anything about the Objective-C programming language. This document will go over all of my knowledge of the Objectiv

Sean P. Myrick V19.1.7.2 3 Nov 8, 2022
Rock - Paper - Scissors game. CPU gives you a sign and asks to win or lose your move. Than you have to decide witch sign do you choose to score a point

RockPaperScissors 2nd challange from HackingWithSwift.com. The CPU gives you a sign (rock, paper or scissors) and asks you either to win or to lose th

Pavel Surový 0 Nov 27, 2021
Collect payments with iPhone, Apple Watch, and Siri using Apple Pay

Offering Apple Pay in Your App Collect payments with iPhone, Apple Watch, and Si

Edgar Papyan 4 Dec 14, 2021
A comprehensive SDK for scanning Digimarc digital watermarks and the most common retail 1D barcodes & QR codes.

##Digimarc Mobile SDK for Apple Platforms The Digimarc Mobile SDK (DM SDK) is a comprehensive and robust scanning software for Digimarc Barcode (Produ

Digimarc 5 Jun 1, 2022
Find and save your favorite places!

Reqs Recommendation app to search for, organize, and save the places you love. TODOs: Implement UserDefaults for settings Complete annotation screen w

Joseph Gilmore 3 Nov 7, 2022
SwiftyCache is a dynamic and auto-managed cache written in Swift

SwiftyCache is a dynamic and auto-managed cache written in Swift. Unlike a simple cache system, it allows you to keep some data even in different executions. Guaranteeing persistence, when desired, without increasing the time required to save or recover data.

Antonio Guerra 3 Aug 28, 2022
iOS Offline Caching for Web Content

Mattress A Swift framework for storing entire web pages into a disk cache distinct from, but interoperable with, the standard NSURLCache layer. This i

BuzzFeed 522 Oct 25, 2022
A lightweight generic cache for iOS written in Swift with extra love for images.

Haneke is a lightweight generic cache for iOS and tvOS written in Swift 4. It's designed to be super-simple to use. Here's how you would initalize a J

Haneke 5.2k Dec 29, 2022