Running your own iPhone applications without paying the developer fee

For those of you wanting to build off-line, native applications for the iPhone / iPod Touch (with the 2.0 Software Update), you might have been disappointed to hear you need to shelve out $99 yearly for the privilege of being able to run your applications on a real iPhone.

Ok, $99 might not be a lot, but one also has to consider when you come to deploy your app for real, it might not pass through the rather stringent screening process to get it to the masses through the App Store.

Wouldn’t it be great if you could deploy any application you wanted for free?

Well thanks to the recently released pwnage tool, it’s now possible to run non-Apple-approved applications on your iPhone though “Jailbreaking”. I’ve spent quite a while trying to figure out how to get this working. Here’s what I have come up with so far.

First of all…

If you are not using a Mac, or you don’t have the iPhone SDK installed, or alternatively the “open toolkit”, then these instructions will be of no use to you.

If you haven’t done so yet, Jailbreak your iPhone / iPod touch via the “pwnage tool”. For reference, this is what I did:

  1. Download the pwnage tool
  2. Create and transfer Jailbroken firmware using the pwnage tool

After you’ve done all that, you’ll probably notice a new application called “Cydia” appears on your iPhone screen. This is basically the way end-users can access a wide range of free “homebrew” applications on their Jailbroken iPhone’s. If you want to deploy your application to end-users, you’ll have to get it into Cydia.

But enough about Cydia for now…

I’ve built applications, how on earth do I get them over to my iPhone?

If you are using XCode, make sure you set the SDK of your application to “Device – iPhone OS 2.0” (or the equivalent if it exists). Then all you need to do is click “Build and go”, and your application should appear on your iPhone.

Now you’ll probably get this rather “Unexpected error” popping up if you try and run your application with XCode.

Unfortunately while the pwnage tool allows you to run any application, that application still needs to be signed. So how do you sign it? Well, the best tutorial for that I have found is the ”Code Signing Guide” on Apple’s website.

You’ll need to make a self-signed certificate using the Keychain Access utility. Then you should run the following commands in a terminal on your built application:

export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform//Developer/usr/bin/codesign_allocate
codesign -fs “Name of your certificate here” /Path/to/your/built/

Unfortunately even when you do this, you still cannot run your app using XCode, so you can’t use any of those fancy debug tools with it. In order to run your application, you’ll have to copy it over yourself. You can either use OpenSSH (installed through Cydia), or [iphonedisk]( I used OpenSSH, as I had problems with the permissions not being preserved with iphonedisk:

scp -r /Path/to/your/built/ root@address_of_your_iphone_or_ipod:/Applications/
Re-load the springboard either by installing something with Cydia, or restarting your iPhone. And hey presto, your app appears!

Update: There is now a way to get your apps working directly from XCode. Simply follow the instructions here, and you should be able to debug your application straight from XCode. Neat!

Note: there are of course other ways to get your app working, but personally I found signing it to be the most obvious.

Right, now my application is ready for public consumption

Great! So how do we get it into Cydia? Well there are two options:

  1. Get the Cydia guy’s to host it in their repository
  2. Make your own repository

Well I couldn’t figure out how you are meant to contact the Cydia guy’s to get your application in their repository. Realistically speaking, this is the only way people are going to find your application, considering there is currently no user friendly way to add new repositories to Cydia.

After all, would you really want to type all of this into the terminal to add a single repository?

ssh root@address_of_your_iphone_or_ipod
echo "deb http://location.of/apt_repository/ ./" > /etc/apt/sources.list.d/apt_repository.list

To conclude

If you are really serious about making money off developing iPhone apps, then i’d cough up and pay the $99 developer fee. That way you’ll be able to target every iPhone / iPod Touch user, while being able to charge a fee for downloading.

If however you have an application Apple are never going to distribute (e.g. emulators), or you are just playing about and don’t mind the lack of XCode integration for on-device debugging, then developing for Jailbroken devices is for you. Personally though i’d recommend you compile your own “open toolkit”, as developing your own unofficial apps using the official SDK is legally questionable.