Skip to main content

Compile iOS Applications

To execute a binary on an iOS device, the source code needs to be linked to the iOS SDK. If you do not specify an iOS SDK it will compile and link to the macOS system, which will not run on the device.

Additionally, if the device is not jailbroken the binary must be properly signed with a developer certificate and the Apple CA certificate. If the device is jailbroken then you can "fake" sign the binary and it will run properly on the device without a valid certificate.

For these examples, we will use the Theos toolkit which will allow linking to the iOS SDK. Theos is a cross-platform build system for creating iOS tweaks.

To compile a small program written in C / C++ / Objective-C:

clang -arch arm64 -fno-stack-protector file.c -o file -isysroot ~/theos/sdks/iPhoneOS14.5.sdk

Note: The -fno-stack-protector flag is not required in most cases, but can be included to disable the stack canary on your program.

While it is somewhat possible to write the tool in Swift, using the Theos tweak development framework, it is not recommended at this time. Trying to link the iOS SDK, and its missing features, is too much of a hassle. It will be quicker to simply use C / Objective-C.