Last Updated: December 26, 2018
· gpakosz

Compiling for iOS outside of Xcode with xcrun

If you have a project which build system is GNU Make based, it's rather easy to compile it for iOS.

TLDR, use:

$ make CC="$(xcrun --sdk iphoneos --find clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 -arch armv7s -arch arm64"

Then use:

$ codesign -s 'iPhone Develoer' ./path/to/binary

Breaking it down:

$ xcrun --sdk iphoneos --find clang

will find out which version of clang needs to be used to target iPhoneOS, e.g. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang


$ xcrun --sdk iphoneos --show-sdk-path

will find out the SDK path that has to be given as -isysroot, e.g. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk.


-arch armv7 -arch armv7s -arch arm64

will build a fat binary targeting armv7, armv7s and armv64 architectures.

To see it in action, you can have a look at my PackedArray project's build instructions and the accompanying Makefile.

1 Response
Add your response


It says that ./build-libspeex.sh: line 55: --with-ogg=/Users/Smeegol/Desktop/Speex/libogg-built/i386: No such file or directory, why i386 cannot be located, it has been created at the previous step?!

It references /Users/Smeegol/Desktop/Speex/libogg-built/i386, and yet in the previous step ...

lipo -create $INPUT -output $DESTDIR/universal/lib/libogg.a

... I see universal in the path name, for one.

Your output directory for the libogg install should look something like this:

${OGGDIR}/include/<include files here> https://kodi.run/
And finally, you have a similar error to your other question: https://teatv.fun/

PATH=xcodebuild -version -sdk iphonesimulator PlatformPath"/Developer/usr/bin:$PATH" \
CC="xcrun --sdk iphonesimulator clang -arch $ARCH $IOSMV" \
CXX="xcrun --sdk iphonesimulator clang++ -arch $ARCH $IOSMV" \
./configure \
... you are missing a "\" after the --prefix line.

3 months ago ·