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

Jeffrey Walton noloader at gmail.com
Thu Sep 2 07:02:32 UTC 2021


On Thu, Sep 2, 2021 at 2:50 AM Neutron <dotneutron at protonmail.ch> wrote:
>
> Jeff, thank you for the clarification on how a simulator operates compared to an
> emulator. The difference was certainly blurry in my head. I did a little more
> digging and it turns out
>
> GOOS_iphonesimulator := ios
>
> is not required when targeting an iOS12.0 simulator. I had initially run it with
> iOS14.5. Perhaps this line can be useful in the Makefile once the project's iOS
> version gets bumped. Still, I would like to know why this happens.

Getting the environment setup correctly is tricky with Clang. With
GCC, you just run 'gcc -dumpmachine' and you can tell what you are
targeting. -dumpmachine does not work with Clang. Clang reports the
host's arch, like x86_64 even if you are targeting iPhone or
iPhoneSimulator or WatchOS or AppleTV.

To get the information from Clang you need to do something like this:
https://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L50. You
have to run the preprocessor with CFLAGS or CXXFLAGS, and look for
defines like __x86_64__ or __aarch64__.

You have to use CFLAGS or CXXFLAGS because that's where you put '-arch
arm64'. Xcode sets this for you in the IDE, but you have to do it
manually when setting up a makefile.

> Just like before on iOS14.5, I'm having issues with creating/editing
> configurations in the simulator, with log messages like:
>
> Saving configuration failed: Error Domain=NEVPNErrorDomain Code=5 "IPC failed"
>
> The message I'm getting may be just as well be unrelated, but a common theme I'm
> seeing is that you can't get Network Extension providers to work on simulators.

Yeah, Apple has some cryptic error messages at times. If you can't
find it while searching, then you have to burn one of those Apple
Support incidences.

> This Eskimo fellow seems to have good insight on the matter.
>
> https://developer.apple.com/forums/thread/46004?answerId=134358022#134358022

Quinn is usually very helpful. He's been supporting Apple development
for as long as I can remember.

Jeff


More information about the WireGuard mailing list