[wireguard-apple] [iOS] Running WireGuard on a simulator
Neutron
dotneutron at protonmail.ch
Thu Sep 2 00:57:30 UTC 2021
Hello,
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
actually builds successfully. I looked through the Makefile and applied some
monkey see, monkey do. It turns out I could get it to link by adding
GOOS_iphonesimulator := ios.
For a moment I thought this was a definite win, but it turns out connecting to
one of the test tunnels doesn't do anything. I hit a dead end after finding this
answer on a forum thread.
https://developer.apple.com/forums/thread/651779?answerId=617050022#617050022
"If you’re talking about the iOS Simulator here, be aware that, because of the
way they interact with the networking stack, NetworkExtension providers only
work on real hardware."
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?
I'm a neophyte when it comes to anything iOS related, so perhaps someone
with more experience can shed some light on the subject.
Neutron
More information about the WireGuard
mailing list