Google Android Development Agency SASS

Tuesday 10 March 2009

How to: building apps on a jailbroken iPhone

With Apple in chaos when it comes to handling membership to the ADP, sometimes we as developers have no choice but to bypass the official process and get things working anyway we can.

I've just had the pleasure of getting an unsigned iphone app to run on a jailbroken iPhone and given the myriad of different methods out there I though I'd write a quick how to.

I'm assuming you're starting out with a standard (locked) iPhone 3G. (I've not tested this on iPod touch). I'm assuming you're at v 2.2.1 as that's all I've tried this with. You're going to need an Intel Mac - I couldn't get this to work on a PowerBook, even though I can write apps and run them in the simulator on the Powerbook. You also need OS X Leopard, thanks Apple :-(

For the prupose of this tutorial, I'm focusing on getting an existing app to run on an iPhone, to create one from scratch you need to download and install the Pwned developer templates, which are easily located using Google...

  1. First off, you need to jailbreak your iPhone. The easiest way I found was to use QuickPwn. DO NOT USE THIS IF YOU WANT TO UNLOCK YOUR iPHONE AT A LATER DATE!! (See QuickPwn website)
  2. Download QuickPwn and follow the onscreen steps, I had my iPhone jailbroken after about 5 minutes.
  3. Fire up Cydia on your newly jailbroken iPhone, and add a new "Source" in the Manage section, using the url: http://www.iphone.org.hk/apt
  4. Locate the package "Mobile Installation Patch" version 2.2.1 in the "Tweaks" section of Cydia and install it
  5. Reboot your iPhone. It should now be ready to accept any application.
  6. You need to create a self-signed certificate in your keychain to sign your apps with. To do this, run the Keychain access utility from the Utilities folder on your Mac.
  7. In keychain access, click on Certificate Assistant -> Create a certificate from the Keychain access menu.
  8. In the certificate name field, enter "iPhone Pwned Developer" and choose "Self Signed Root". Check the "Let me override defaults" box and click continue
  9. On the next screen, enter a serial number (Any number will do as long as it's not already used in a certificate). Change the certificate type drop down to "Code signing"
  10. Fill in your details on the next screen and then click continue through the rest of the screens.
  11. Once you get to the end, you'll see a new certificate and key pair called "iPhone Pwned Developer". You can now close the keychain access utility.
  12. Next, locate your projects "Info.plist" file and add the following: 

    <key>SignerIdentity</key>
    <string>Apple iPhone OS Application Signing</string>


  13. Save the file and run XCode
  14. Open your project properties in Xcode and add two user defined settings as follows:

    PROVISIONING_PROFILE_ALLOWED NO
    PROVISIONING_PROFILE_REQUIRED NO

  15. In your project settings, make sure that your code signing identity is set to "iPhone Pwned Developer". For reference, my other important settings were: Valid Architectures=armv6, C/C++ Compiler=GCC 4.0
  16. Now, click open the Organizer window and verify that your iPhone is listed under devices. If it isn't try rebooting it and restarting XCode, it should appear. (Obviously plug the cable in first...)
  17. Once your iphone is connected, make sure you set your target to "Device - 2.2.1", clean your build and then click "Build and Go". Your app should now run and appear on your phone!

Even if this doesn't help anybody else, it at least gives me a record of what I did to get things going. It took me two days of messing around to get this working (admittedly some of that was re-installing OSX on the MacBook).

One final thing - I take no responsibility for what you do with this, nor if you brick your phone, wipe your hard drive or blow up the office. If you're not sure what you're doing, don't blame me when things go wrong!