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/


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

will find out the SDK path that has to be given as -isysroot, e.g. /Applications/


-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.