Dev:Compiling iOS applications on-device

This article will be useful to anyone that does not have a Mac to compile apps or does not want to pay the $100/year fee to run code on your own device.

You don't even need a secondary desktop or a laptop to do this! However it is not recommended to actually code the app directly on-device, unless if you're a masochist or something.

= Prerequisites =

Aquire an iOS device with iOS 5 or higher and jailbreak it.

This technically could work with lower iOS versions, but the available toolchain on Cydia was compiled for iOS 5.

= Install the toolchain =

Open Cydia and install these:


 * Tape archive
 * iOS toolchain
 * OpenSSH
 * wget

Or just run  as root (default password: alpine).

= Get the SDK =

They are found here: http://iphone.howett.net/sdks/

You can literally use any SDK you want as long as they have the frameworks you need, however it is recommended you use the iOS 7 SDK or higher as the lower ones do not support arm64 (optimized for iPhone 5s and higher).

Right click "Download" on one of the SDKs and copy the link.

SSH into your device (user: mobile, default password: alpine) and run these commands:

Boom. Your device can fully now compile iOS applications.

= Creating a vanilla app =

Creating the app structure
Login as root (default password: alpine) and run these commands:

Then create a file Info.plist in /Applications/Test.app/ with the following contents:

Then switch back to mobile</tt> and run:

If you did everything right, once the command is done running you should see this on your homescreen:

(On iOS 6 and lower, there would be no lines in the white square)

When you try to open the app, it will crash! That's because you actually haven't written anything yet.

Actually writing a working app
So let's make a simple application real quick. This will not be the best written app in the world but it will have enough explanation for you to understand what you need to do if you want multiple files.

Make a folder in /var/mobile</tt> called test_app_src</tt>.

Change directory into this folder and make 3 files: main.m</tt>, TestLabel.h</tt>, and TestLabel.m</tt>.

Compiling
Run these commands:

If you didn't get any errors, when you list the contents of the directory you should see this:

Copy Test</tt> into /Applications/Test.app/ and overwrite the old empty Test</tt> file you created earlier.

Then, go ahead and open the app again and you should see this:



WAU, that AMAZING!!!

That's pretty much all you need to know to get started. If you want to use more frameworks (like AVFoundation or something) add the `-framework AVFoundation` flag during the last compile step (kinda like how I used UIKit and Foundation).

Enabling automatic reference counting (ARC)
Add the -fobjc-arc</tt> flag when compiling.

Icons, default backgrounds, entitlements, etc
Check out Apple's documentation on the subject. You can also look in any of the other Info.plist</tt>s in the /Applications/</tt> directory on your device! Cydia.app</tt> would be a good place to start.

Uninstalling
Delete it from /Applications/</tt> and run uicache</tt> as mobile again. iOS thinks it's a system app, so you can't delete it like a normal iOS app.