Developing for a jailbroken iPhone, A to Z (iPhone 2.2)

Vital iPhone stats for this post:
iPhone OS version: 2.2 UPDATE 7/11/09: OS 3.0 procedure here
Jailbreak status: Jailbroken using Pwnage Tool 2.2, old baseband preserved (see post here, coral cache)

The Goal: Get live on-device XCode debugging without being a paying ADC member.

Abstract: The iPhone uses code-signing to restrict what gets run on the device. Under normal conditions, this means that John-developer signs up with ADC (Apple Developer Connection) and gets, among other credentials, a code signing identity. He downloads a certificate, plugs all the info into XCode, and when he compiles his project for debugging or release, it gets signed with this certificate. When it gets transferred to an iPhone (say, for debugging) or released to the App Store, this signature gets checked to ensure that the code came from a registered, trusted ADC member.

What WE want to do is run our own code, developed in XCode, on our iPhone without this valid certificate from Apple. Part of this process allows code from OTHER non-ADC-signed developers to run on other phones, but that’s not the real point. The goal of THIS tutorial is to make the Build and Go live-on-device debugging work on a jailbroken iPhone without the proper signature, in other words without the need to pay. Note: this does not allow you to develop for the App Store. This is only good if you’re only developing for yourself or you plan to distribute only for jailbroken phones/iTouches.

The Process:

  1. You’ll need a jailbroken iPhone (or iTouch). The specific jailbreak method I used is posted at the iPhone Dev Team link below, but it doesn’t much matter. It only matters that your device is jailbroken and has Cydia installed.
  2. You will need a signing identity. We’ll break the check such that it doesn’t have to be an official ADC one, so you can make your own using this guide from apple (coral). What you are doing in this step is creating a “Self-Signing Identity.”
  3. Break signature checks on your phone. This used to be a big pain. Luckily, there is a super-easy way to do it these days. Add the repository http://iphone.org.hk/apt to Cydia on your phone. Then, update your sources (should be automatic) and search for the MobileInstallation Patch. The current version supports os 2.2, and I’ve found that it gets updated pretty quickly after new releases. Note: There is an alternate version of this step, should this method break for any reason. You can also add the repository http://cydia.hackulo.us and use the package MiPatch. The two do the same thing. I’ve not tested this alternate method, but I have no reason to suspect that it doesn’t work.
  4. Make a backup of the file /Developer/Platforms/iPhoneOS.platform/Info.plist then edit it to include the bit in red:
    <key>NATIVE_ARCH</key>
    <string>armv6</string>
    <key>PLIST_FILE_OUTPUT_FORMAT</key>
    <string>binary</string>
    <key>PROVISIONING_PROFILE_ALLOWED</key>
    <string>NO</string>
    <key>PROVISIONING_PROFILE_REQUIRED</key>
    <string>NO</string>

    <key>SDKROOT</key>
    <string>iphoneos2.2</string>

    (step copied from post two of iphonesdkdev.blogspot.com below)
  5. (Updated 12/24/08) Open your project and go to (menu) Project > Edit Project Settings. In the list of properties, find “Code Signing Identity” > “Any iPhone OS Device” and click in the empty box. Assuming there are no entries in the menu, click “Other” and type in the same name you used to generate the code signing certificate above in step (2). For example: in step 2, I used the name “iPhone Developer” and that is exactly what I put in this field. Hit OK and close that settings window. This setting should persist in future projects, and you shouldn’t have to do this again (whereas, for example, you’ll have to repeat step 6 for each project).
  6. Add the following to the Info.plist for your project:
    <key>SignerIdentity</key>
    <string>Apple iPhone OS Application Signing</string>

Information in this post came from the folowing places:
http://www.246tnt.com/iPhone/ (coral)
http://iphonesdkdev.blogspot.com/, specifically the posts here (coral) and here (coral)

UPDATE 12/24/08: I realized after a few comments from other blogs that I totally forgot to add the step where you actually USE the code signing certificate you created. I believe that step 5 is correct, so please re-try this. Otherwise, the first post above from iphonesdkdev.blogspot.com should have, somewhere inside, what you need. If the procedure above doesn’t work, please try looking around that post and let me know what step I need to add. It’s difficult to recreate exactly what I did now that my setup works.

UPDATE 1/14/2009: One of the commenters pointed out a key point: After you’ve generated the certificate and configured xcode, you MAY have to restart to get things working, else you may get an “Codesign error: no certificate for identifier “iPhone Dev” was found in your keychain” error.  If a restart doesn’t fix it, see my comment below following his.

43 Comments

  1. December 14, 2008

    hello
    Do you want to contribute with us (I need blog writer)?
    if yes please email me at:
    [email protected]

    Sorry for my English!
    Regards,
    Mojtaba Cazi

  2. DSS
    December 21, 2008

    Thanks so much!!
    One thing I was stuck on is that it seems you have to set “Code Signing Identity” / “Device – iPhone OS 2.2” to your self-signed certificate name in the properties of BOTH the project and the target. (This may be an issue for preexisting projects.)

  3. December 21, 2008

    Yes, in fact I’ve been meaning to edit this post for a while – someone noticed that, while this procedure calls for a self-signed certificate for code signing, it’s never actually used. I forgot to add that step, but the problem is that I don’t remember EXACTLY where it goes, so I have to retrace my steps a bit. I’ll probably take a look tomorrow morning.

    In specific response to your question, yes. I do recall that that certificate had to be added to both the project and the target, but luckily (or unluckily for me retracing my steps) the setting persists for new projects.

  4. ion
    December 24, 2008

    alex, have you retraced your steps yet?

  5. ion
    December 27, 2008

    Is “CodeSign warning: provisioning is not applicable for product type ‘Application’ in SDK ‘Device – iPhone OS 2.2’; ignoring…” a normal error?

  6. December 27, 2008

    I get lots of assorted errors and warnings, but if the app runs on the phone like it should, I just don’t worry.

  7. Duncan
    January 14, 2009

    I can’t seem to get this working. Whenever I try to run it, I get this error:
    Codesign error: no certificate for identifier “iPhone Dev” was found in your keychain

  8. Duncan
    January 14, 2009

    Scratch that. I rebooted my computer, and now it works fine.

  9. January 14, 2009

    I’m glad to see that it was just a restart issue, I’ll add to the post that you may have to restart your computer to get things to jive. For future rererence, if you get this error, it’s probably because you didn’t keep your name convention consistent throughout the steps. For example, I can make a certificate for “Joe Schmoe McMann” as long as I use the same name while setting up XCode. I reccommend you just use the default name above to keep everything consistent and eliminate a source of error, but that’s what you should look for first if you still get this error after a restart.

  10. February 4, 2009

    Hi alex,

    It worked for a jailbreak iphone 2.0 without adding (step 6):

    SignerIdentity
    Apple iPhone OS Application Signing

  11. Yehudaz
    March 26, 2009

    I get the following error:

    CodeSign error: a valid provisioning profile is required for product type ‘Application’ in SDK ‘Device – iPhone OS 2.2’

    Any comments for me ?

  12. March 26, 2009

    I think that could be because you accidentally skipped step 6. I think that’s the only time I’ve ever gotten that error – step 6 tells the SDK that it doesn’t need to bother looking for provisioned devices.

  13. Yehudaz
    March 29, 2009

    Hay Alex

    I did write step 6 a checked for spelling and even Tab margins.
    With the same result.

    Maybee it is connected to the fact i reacenently upgrades the Xcode
    to the supported 2.2 from en earlier version that supported 2.1.

    Any more ides ?

  14. Rob
    April 17, 2009

    Thanks for the excellent tutorial, this was a huge help for me.

    @Yehudaz & ion

    In case anyone else is getting the “E800003A” error where it pops up two times when building for the phone, make sure you have rebooted both the Mac and the iPhone. It didn’t work for me until both were restarted.

    Hope this helps someone.

  15. Michel
    May 5, 2009

    This tutorial worked for me. Thanks.
    The following problem…
    CodeSign error: a valid provisioning profile is required for product type ‘Application’ in SDK ‘Device – iPhone OS 2.2′
    …was solved by simply reboot the Mac and iPhone as suggested by Rob

  16. May 22, 2009

    Hi again!
    Thank you for this guide! now i can run my own apps on the iPhone but i can’t use Xcode iPhone simulator any more 🙁
    what should i do?!?

  17. May 24, 2009

    I’m not exactly sure what could be causing that, do you have any errors that show during the build process? The best thing I can think of is that you’re just forgetting to reset which SDK you’re using. Use the Project > Set Active SDK menu to switch between building for the Simulator (your iPhoneOS version) and the Device (your OS version). I actually have two more posts to write right now, one of which includes a tip to make this easier.

  18. June 3, 2009

    It doesn’t seems to work with iPhone SDK 3.0 beta5!!!
    any idea?

  19. June 4, 2009

    Unfortunately, I don’t actually have the 3.0 betas. I mean, I’ve never paid for ADC, so I don’t get them, and that’s also why I develop on jailbroken devices. BUT, I actually just got an old iPod touch, so I may just drop the $100 so I can release apps to the store. I’ll update this procedure as soon as I get my hands on 3.0 though.

  20. Gabe
    June 18, 2009

    I’m running Leopard through VMWare since I don’t have a Mac but am interested in iPhone development. Everything is working great, but I am unable to get USB in emulation so I’m unable to build/run on my touch. What I’ve tried to do instead is use the Windows iPhone browser and copy the compiled files over to the /Applications folder. My application wasn’t showing up in Springboard, so I poked around the internet a bit and found that I should run UIKit Tools (found on Cydia). When I did this, my application showed up in spring board, along with the icon and the correct name.

    The problem I am having however, is that when I try to run the application I get: The application “iPodTestApp” cannot be opened

    Could this be because I somehow got messed up in the security certificates? I installed MobileInstall Patch and I am able to compile in iPhoneOS mode (as opposed to just sim). I am however getting: “CodeSign warning: provisioning is not applicable for product type ‘Application’ in SDK ‘Device – iPhone OS 2.2′; ignoring…”.

    I’m using a jailbroken second gen touch with 2.2.1 on it.

    My test program is very very simple; it’s just a button which displays test in a label when it’s tapped. It works perfectly fine on the simulator.

    Any help would be appreciated!

  21. June 18, 2009

    Looking over all of those symptoms, it seems most likely that the disconnect where the device doesn’t actually talk to Xcode is the problem. So there are a couple of things to consider here. Obviously, if you can’t actually connect the device over USB to your Mac VM, you can’t do any real DEBUGGING on the device, only testing. That said, my understanding is that Xcode handles device provisioning by device UID, the unique ID assigned by hardware characteristics to every UNIX-style system, iPhone included. That is, when you connect a device with Xcode open, the provisioning system sees it, makes note of its UID, and adds it to the pool of available provisioned devices. Normally this involves a few other checks, but the above and the jailbroken thing breaks them.

    I’m just guessing here, but it could be that, when you build using the “device” SDK in a Debug configuration, it pays attention to provisioned UIDs, which your phone is obviously not a member of as far as Xcode is concerned. It may, however, work to simply switch to the ‘Release’ build for any of the builds you want to try on the phone. It won’t make much of a difference since you can’t do active debugging anyway, and the lack of debugging hooks will only make the app slightly snappier and smaller in terms of footprint.

    Try it and let me know how it goes.

  22. Gabe
    June 19, 2009

    Thanks for the quick reply!

    Forgot to mention in the earlier post, but I got the exact same error using either release or debug mode.

    I’m working on getting the USB working; I read somewhere that someone managed to make it read (if poorly) a USB key. It’s a long way from xcode seeing a touch, but I’ll keep plugging away.

  23. June 19, 2009

    hi again!
    did you install iPhone OS 3.0 ?!
    i did it & it’s works fine! but now i want to start developing for it! is there any way to develop for iPhone 3.0 without paying apple 100$ ??

  24. June 19, 2009

    The jailbreak is officially out, and with the release of OS 3.0 wednesday, so is the SDK for everyone who’s a non-paying developer. As such, I’m jailbreaking my phone now, and I’ll see about how the new SDK plays with jailbroken phones ASAP. I’ll probably totally remove the prior SDK as well, simply so that I can write a full procedure. I’ll make a new post about it and update this one to reflect that, so stay tuned.

    Gabe, that’s a bummer for sure. You might look into Saurik’s various documentation online about how to distribute via Cydia, as that probably contains the steps you need to complete somewhere. Sorry I can’t be of more help right now, but I may look into it later. Let me know if you figure it out.

  25. Nicu
    June 19, 2009

    Hi guys,

    This method worked perfectly for 2.2 SDK but after installing the 3.0, I’m getting this error message when I try to run the application on the device:
    Code Sign error: a valid provisioning profile matching the application’s Identifier XXX could not be found

    I followed all the steps.
    Can someone help?

  26. June 20, 2009

    @Alex Whittemore – Thanks for fast reply!
    I’m waiting for your new article about iPhone OS 3.0

  27. oxygen
    June 22, 2009

    @all
    I am using iPhone SDK 3.0
    Code Sign error: a valid provisioning profile matching the application’s Identifier … could not be found
    🙁

  28. Average Joe
    June 25, 2009

    I installed iphone SDK 3.0 without knowing this. I really need a fix for this!

  29. June 26, 2009

    same happend to me after upgrading to sdk 3.1.3!
    tried it by changing iphoneos2.2 in
    iphoneos3.0 in the info.plist….
    no way: “CodeSign error: code signing is required for product type ‘Application’ in SDK ‘Device – iPhone OS 3.0′”

  30. Martijn
    July 3, 2009

    No solution yet for SDK 3.1.3?
    Cheers

  31. Falk
    July 22, 2009

    Hi Alex,

    I gave up building an *.ipa file and tried to run my app by building it to iphone instead (2.2.1)

    I followed your instructions and got the following error during Build “Error from Debugger: Error launching remote program: security policy The Icon appears on the phone, but when i try to open it i get “The application “myapp” cannot be opened”.

    Can you think of something I forgot?

  32. Falk
    July 22, 2009

    Fixed the problem myself by downloading an app from itunes. Next error in line is the following:
    “error from debugger: putpkt; write failes: Broken pipe”. Really need helo with this.

  33. minimal
    September 16, 2009

    Is it Yes written interesting, but continuation will?

  34. jhon
    October 7, 2009

    Hi ..
    I am using Xcode 3.1.4 and iPhone SDK 3.1. I have developed and application and i need to put it into my jailbroken iPhone.. Please someone guide.. I did some stuff as mentioned above but nothing worked out..

    Thanks for help..

  35. johnson
    December 8, 2009

    I have a jailbroken iPhone 3g(firmware 2.2),and I am using sdk 2.2.1, XCode version 3.1.2. I am trying to debugged my application by bypassing the security policy, but when I Build and Go, the icon comes up on the device but it gives the error like this at my XCode “Error from debugger:Error launching remote program: security policy error.”. Please help.

  36. […] lebih rumit (untungnya di versi ini lebih mudah), bagi yg menggunakan SDK 2.x caranya bisa dilihat di sini,  (jangan lupa install “Mobile substrate” dari saurik), untuk SDK 3.1.3 target […]

  37. Luka
    April 23, 2011

    Hi everyone, I an registered developer and I would like to install my (developer signed) app on jailBreaked phone. Is it possible to use .app folder with Cydia to do it or I’ll have to go through the process of defining self signed certificate? Thanks, L

Leave a Reply

Your email address will not be published. Required fields are marked *