Last Updated: February 25, 2016
· 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.

Say Thanks
Awesome Job

B6c77ad0 c95b 11e7 8263 8f89080b8db6
Ruby Developer Backend
Austria (Vienna or Linz)
Full Time