Saturday, October 25, 2008

Success with iPhone Provisioning Profiles

I spent all day (literally, all day) trying to setup my iPhone app such that it would run on my physical iPhone. For those of you who have problems, some of this may help you.

My application has always run OK in the simulator. Since I've had the phone for a few months now, and I'm recently a certified Apple iPhone Developer (paid the $99 too) I thought it was about time to get my app on my iPhone.
I just didn't think it'd take me an entire day. And by entire - it was actually more then a day; I had setup my 'Team' and done the root CSR request about a week earlier. Over the span of the week, I had skimmed the documentation. And I had scheduled today, the entire day for iPhone stuff. Meaning code, and putting the app on the phone.

I started this morning. Followed the doc's in the how-to tabs. And had absolutely no luck. From the dreaded (0xE800003A) error, to (0xE8000001), "handle_install: Installation failed", (0xE800003A) Verifying Application, etc etc. "

Late this afternoon I gave up; I shut everything down, rebooted, deleted /Developer, rebooted, then downloaded Xcode 3.1.1 and the 2.1 iPhone SDK. And proceeded to start over.

After all the installations, then I went into Xcode "documentation" and let it "download" . Then I devised a strategy - I had been doing bits and pieces of trying different things all da long -- things people suggested in Apple's Developer Forums and many other "non-official" sites (easily findable via the Google). I decided I would start completely over with my developer setting as well. Here's what I did:



  • Deleted Xcode and iPhone SDK (mentioned above) and reinstalled. I don't think you must reboot, but after an XCode installation your boot cache's will be updated so I think it's a good idea to do the reboot.

  • I deleted ~/Library/MobileDevice/Provisioning Profiles/*.

  • I went into the iPhone Developer Program and revoked my certificate and re-did it, as well as deleting all of my provisions.

  • Then I created a new app ID. I called it "My Application Suite App ID" . I gave it a wildcard. Why? Well, the more I'd read, the more I decided this was the correct way to do this. It would let me put any iPhone app that I compiled on my iPHone. Oh, and don't use the "App ID Name" of "test". I spent the afternoon getting frustrated trying to get all this to work. The system does not seem to like things named with 'test'. YMMV.

  • Once the Privisioning is approved and you can download it, drag and drop the file onto XCode. That installs it.
  • Now, take the iPhone, goto settings:general::profile and delete any out of it. reboot the phone. launch xcode, then plug the phone in. switch xcode and goto the organizer (cmd-control-o) and make sure your provision is added (checked) to the iphone device. One the phone it'll look like this:

  • Now we create a simple Xcode app to see if it'll even run on the phone., In Xcode, cmd-shift-n for a new project. It will be of type iPhone Navigation-Based-Applicaiton. (The following is in the iPhone Develper Docs, but I'll quickly summerize for the sake it): Call it 'Foo' or whatever. Expand the Targets folder in "Groups & Files". Click on 'Foo' within the Targets folder. Click the "info" blue-circle icon in the top bar of the window. Switch to 'Build' Tab. There's section called "code signing". You want to change the "iPhone Developer" to "iPhone Developer: Firstname Lastname" and they "any iPhone OS Device" to the name of your provision, namely in my case "My Development Provisioning Profile". Close the window.

  • Then test it all cmd-r. In a minute or so the app should be running on your phone. Not that it'll do much, but that's left for you to hack at :)

  • There were a few sites I found helpful in figuring all this out: preflightingapplication errors (0xe8000001), mac rumors forums, Debugging iPhone provision profiles/certificats and Apple's discussion forums.


    2 comments:

    IfeelMystuff said...

    Thank you. Your scorched earth policy worked for me, and I finally am able to run my apps on my phone.

    Much appreciated.

    cppdude said...

    thanks very much... been trying to make this work for two days now... been to a lot of how to's, both official and non-... but this took me only about 10 minutes tops... very nice :)