[wireguard-apple] [iOS] Running WireGuard on a simulator

Jeffrey Walton noloader at gmail.com
Thu Sep 2 01:20:36 UTC 2021

On Wed, Sep 1, 2021 at 9:00 PM Neutron <dotneutron at protonmail.ch> wrote:
> I've tried running wireguard-apple on an iOS simulator and encountered some
> trouble during the compilation of WireGuardKitGo. I did this on an Apple M1,
> which I thought at first would be the culprit.
> The Go version is "go1.16 darwin/arm64". The build process fails at
> # runtime/cgo
> Undefined symbols for architecture arm64:
>   "_darwin_arm_init_mach_exception_handler", referenced from:
>       _x_cgo_init in _x004.o
>   "_darwin_arm_init_thread_exception_port", referenced from:
>       _threadentry in _x004.o
>       _x_cgo_init in _x004.o
> ld: symbol(s) not found for architecture arm64
> This issue was reported a few times in Go's issues section, e.g.,
> https://github.com/golang/go/issues/45772#issuecomment-874616905
> Further head banging lead me to the discovery that
> xcodebuild -target WireGuardiOS -sdk iphoneos14.5

Yeah, whenever you start seeing problems with missing symbols related
to exception handlers, you should look at the target SDK. I see it a
lot when trying to cross compile for Apple WatchOS and AppleTV when
using the wrong SDK.

Besides -sdk, other ones to look for are -miphoneos-version-min,
-miphonesimulator-version-min, -mappletvos-version-min,
-mappletvsimulator-version-min, -mwatchos-version-min and
-mwatchsimulator-version-min. If you drop them too low, you will break
during link with the missing exception handlers.

I think what happens is, the headers mostly work with a lot of
different targets. But the exception handlers are specific to a
particular SDK, and you only have a limited range of them installed
(otherwise, you have to install older versions of Xcode and older

I don't know how Go affects things. I usually work with native C/C++/ObjC code.

> I don't have an actual iPhone on hand at the moment,
> so I guess the question is, is the project supposed to
> work only on real hardware? Was that flag left out
> intentionally? If so, is there a way to get it to run
> properly on simulators?

In the past, the network stack was crippled on the simulator. I don't
know if that's the case nowadays. I think Android is about the same.
It is hard to test some of this stuff on a simulator or emulator.


More information about the WireGuard mailing list