Saturday, January 19, 2013

Getting down with Provisioning Profiles

So, I'm going to give an another crack at getting my programming to run on the 4s. So, last Jan 1, I ending up getting tangled up in a web of developer certificates, provisioning profiles, team certificate requests, organizer displays showing the wrong name and the right device, and so forth and so on until I was thoroughly lost. I'm still lost, but have no choice but to try to hack my way out of this digital forest. Do other people have this kind of trouble?

 Oh, yeah, one thing I did do was download Xcode 4.5, which was the one thing I did figure out I needed. Let's bring that up and see what happens when I try to run the app. Ok, when I bring up the app, I get a much clearer message than last time (I think): "Provisioning profile 'JLPT Vocabulary Quiz Development Profile' has expired".

So, I guess the provisioning profile is stored on my macbook, say on the keychain, or with the app, as opposed to on the device.The reason is that the phone is new, and therefore the provisioning profile couldn't be on my device.

 Ok, I went to organizer, and all the profiles related to my app were expired. I tried pressing the "renew" button for the profiles, but nothing. So, I'm just going to delete them. How could they have been on my iPhone anyway?

Ok, I just went to https://developer.apple.com/ios/manage/provisioningprofiles/index.action and deleted the profile there, but I still get the same error when I do a build on Xcode. What next? Wow. I think I might have screwed up with all my deleting. I saw an entry on SO that said you just have to right-click on your device in organizer and then just select "add device to profile". But - the profile is gone. I just deleted it. Rats.

So, now I think I have to recreate it.  Ok, in the provisioning portal, under provisioning, the developer tag, I selected "new profile'. I pasted the profile name in. For the app name, it gave me a list of app names to choose from. Three of them roughly match my app name, so I'm picking the one that looks most final (these are names I would've created before.

Wow. It's put the expired profile names that I deleted back in the list! Amazing. And the one I just tried to recreate now has a "pending" status. Let's refresh it. Active!

Ok, I think I need to download it now or something. Ok, when I download it, it hopped into the download folder, and I dragged to to the Xcode icon (btw, why don't they call it xCode? That spelling is so much more intuitive). Xcode automatically went to organizer after that, and now it says the profile is valid - let's try a build.

Nope. Not yet. Let's try the "add device to provisioning portal" again, since the profile was created with only the old iPod as the device.

Well, I tried doing the same thing with the other provision profile with my app name, and somehow the organizer was showing me the expired profiles again! (which I deleted).

Btw, I also modified the settings in Xcode so to add the profile name for signing on the app store, debug and whatever the other one is.

Ah, now at least I'm getting a different error message: "Provisioning profile '814FA14A-2A11-4447-BB5A-1CFE7AC042FC' can't be found" No idea why it's looking for that crazy string.

Ok, this SO entry looks *very* interesting (437 upvotes, never seen so many).

"Sometimes your xcode project file gets messed up, especially if you have an old project and first created it with an older version of xcode/iphone sdk. What you need to do is open up the project file in a text editor, search for the 'long string' from your error and manually erase that line. In fact, you should just go ahead and erase any line that points to any provisioning profiles. Then reopen the project in xcode, go to the settings and reselect your new profile. This clears up issues like that most of the time.

The lines that point to the provisioning profiles will look like this:
 PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";

also in the same thread:

"The .xcodeproj file is actually a directory, like an application bundle, If you right click it in finder, you can select show package contents, and then you will see several files inside (or in terminal just cd into it). The actual project file is the one in there with a .pbxproj extension. Once you open it with a text editor the lines you are looking for should start with 'PROVISIONING_PROFILE = or' '"PROVISIONING_PROFILE[sdk=iphoneos*]" ='. Delete all of those and then you should be good"

also:

"I found that, in addition to the above, I had to delete all of my profiles, re-download them from the provisioning portal, and reimport them into XCode. Then, in Build Settings / Code Signing, select the proper profile for all build configurations.

However, in Xcode 4.2 and later, there is a much easier way to access this text and select and delete it. In the Project Navigator on the left, select your project (the topmost line of the Project Navigator). Now simply choose View > Version Editor > Show Version Editor. This displays your project as text, and you can search for PROVISIONING and delete the troublesome line, right there in the editor pane of Xcode."

Phew. I think I'll tackle this tomorrow. Hopefully, I've finally gotten to the bottom of this tangled web of yarn.


No comments:

Post a Comment