Tuesday, January 1, 2013

iO6 6 needs a Xcode 5!

Well, I'm getting back into iPhone development *a little bit*. I've haven't been doing it for a while because of, well, other priorities, like locking down this new job I've got. But I did some development on the app a while back, and since then I've gotten an iPhone 4S (nice!). I strongly recommend for anyone Virgin Mobile's plan, which provides *unlimited data* for $30 bucks a month. The catch is you need to purchase the iPhone 4 or 4s model, with the 4s running at around $400 bucks as of late December.

Anyway, so my first obstacle is getting the program to run on the 4s. It appears (the device) on the organizer, but when I try to run the app, it gives me an error message: "Xcode cannot run using the selected device." "No provisioned iOS devices are available with a compatible iOS version. Connect an iOS device with a recent enough version of iOS to run your application or choose an iOS simulator as a destination".

Well, that's a surprisingly wordy yet somewhat helpful message. I suspect that it's only checking for previously provisioned devices, which at this point is my iPod touch, which I haven't updated for a while and therefore probably is running the old version of the iOS?

I'm not sure, but I think I need to provision the new device (4s) for development. Ah, actually, I missed this message on the Organaizer: "The version of iOS on “My Names’s iPod” does not match any of the versions of iOS supported for development with this installation of the iOS SDK. Please restore the device to a version of the OS listed below, or update to the latest version of the iOS SDK; which is available here."

Hmmm, I get conflicting advice from Google. I know there's a yellow dot next to the device name on Organizer - it should be green. Also, it's called "My Name's iPod Touch" which is bad since I'm connected to a 4s, yet its showing up, correctly, as an iPhone 4s as the device type.

Also, I'm pretty sure I never provisioned it for development or anything else yet.

So...what does it want? I'm thinking I need to provision this device, at least. If I right click on provisioning, and click help, I get a menu, which leads me to this:

Obtaining Certificates and Provisioning Profiles
 1. In the Devices organizer, select Provisioning Profiles in the Library section.
 2. Click Refresh.

What is a provisioning profile, exactly?
 "A provisioning profile is a collection of digital entities that uniquely ties developers and devices to an authorized iPhone Development Team and enables a device to be used for testing."

Great. Clear as mud.

"A Development Provisioning Profile must be installed on each device on which you wish to run your application code."

Well, whatever this frikkin' development provisioning profile is, it needs to be on the device. So I need to do this somehow.

"Each Development Provisioning Profile will contain a set of iPhone Development Certificates, Unique Device Identifiers and an App ID."

Brilliant. It needs an "iPhone Development Certificate" - another mysterious piece of digital gobbledy-gook which this russian doll of a process throws at us.

"Devices specified within the provisioning profile can be used for testing only by those individuals whose iPhone Development Certificates are included in the profile."

Ok, I will need a developer certificate - for inclusion in the developer provisioning profile - which must be installed on the device. Is there a PowerPoint that could make this clearer? With all their money, you think Apple could have better docs than this.

"A single device can contain multiple provisioning profiles."

Confusing. So, you have the profile. It has a collection of development certificates, device ids, and an app id. It's easer to think of the development certificates as "developer" certificates, since they are tied to individual.

Only one development provisioning profile per app, it looks like.

So for me, I just have my app, my developer/ment certificate, and my iPhone (I don't care about the iTouch just now).

Brilliant. more legalese from the help screen:

 "Obtain your code signing certificates and provisioning profiles to run apps in development on your development device."

Now I need a code signing certificate.  There seems to be some implicit assumption that I actually know what a code signing certificate is.  I'm assuming it is different than the developer certificate, I guess, and certainly different than the provisioning profile (which is for the developer/app/device combined, not just the developer).

"You must enter your development-team credentials so that Xcode can download the provisioning profiles containing your development certificate."

Umm...wait - I'm not on a development team. Is this something I need to contend with? And, where do I enter the credentials? Btw, what is a "development team" in this context and why do I need to know about it?

"If your development team does not have a development certificate for you, Xcode requests one."

Highly unlikely that would be the case, since I'm the only developer and have no idea who or what the "development team" is supposed to be.  Also, I resent some obscure scrap of data on some Apple server being referred as a "Development Team" as if it was some kind of, you know, actual flesh and blood entity.

"If your keychain does not contain your development certificate but your team has the certificate, Xcode downloads it from your team."

Again, the team. How does Xcode know which "team" to request it from, anyway?

"If your role in the development team is Member, inform the appropriate person in the team that there’s a pending certificate request."

Great. Now I'm supposed to know what my "role" is on this heretofore unknown "team". And what would this "appropriate person" do with this knowledge of my pending developer certificate request?


"If necessary, after the request is approved, follow the steps again to download your development certificate."

Some happy circumstance will have occurred where my cert is now created and available.

"If you are the team distributor, Xcode requests and downloads your team’s distribution certificate, in addition to downloading your development certificate."

A "team distribution certificate"? I can't take much more of this.

So, what is a certificate again? I think it's just a digital set of bits which can be encrypted by a public/private or private public key combination.

Appears to be a file with some info about the certificate's owner, and has the owner's public key. There's this whole thing about the certificate is signed by the CA (issuing authority) by creating a "hash" of the file using some kind of algorithm, e.g. MD5, then encrypting it using their private key.

Then, when your system receives the message, it checks if the certificate is from a a trusted issuer (which it keeps in a list) and if so, the system uses its public key (stored with the CA in the list) to decrypt the hash value (which means it came from them, if your system succeeds in the decrypt of the signature). Then, you run the decrypted signature (the contents of the cert) through the same hash algorithm, and it matches (the one that came with the message?), then you know it hasn't been tampered with. Whew.

So, I guess you get a certificate issued to you by Apple. A Developer certificate. Now, how does that help us get this app running? It's got to be connected the provisioning profile for your device and app, so your app can run.

So, that's what we're trying to accomplish.

From the dreaded "help" file:

"In the Devices organizer, select Provisioning Profiles in the Library section. Click Refresh."

Well, that option isn't there, but there's an intriguing one called "Add device to provisioning portal."

What might a provisioning portal be? Is this addition simply a way for apple to keep track of apps you make?

Anyway, let's see what happens.  Hmm... "No iOS Development Certificate Found" "No iOS development certificate was found. Would you like Xcode to request one for you?"

Well, I thought I had one, otherwise how could I have tested an app on my iPod touch? Or do they mean on my iPhone?

Well, I think I'm going to go ahead and let Xcode request it. It should already be in my keychain, but, I don't remember off the top of my head how to get at it. I'm just going to plunge ahead with this.

Xcode says "Submitting CSR", then "waiting csr approval". then "checking for pending csr". Now it says "No iOS Distribution Certificate Found" and "would you like Xcode to request one on your behalf?" Well, I mean, I had one of those too, but let's go with it. Xcode (again) says "Submitting CSR", and I missed the rest, but now it says: "Export Developer Profile?"

"Xcode added a signing certificate to your keychain. To ensure you can export code signing on other macs, you can export a developer profile that contains a backup of all your certificates and profiles. Would you like to export your developer profile now?"

Well, I don't have another Mac, but my wife and daughter each have one. Anyway, "Export" is the default, so let's hop on that train.

"Save as: DeveloperProfileExport and give a password. Hmm...well, now I have a valid "iOS Team Provisioning Profile" which shows up in my devices list, but IIRC, I had to create a profile specifically for this app."

Let's try to run the app.

Nope. Same problem.

Well, I selected a base sdk, and now my .app is showing up as red in the product folder. One wasn't selected at all before that. I think that this is maybe an issue with the SDK as the original message stated.

\Duh. I should've seen this earlier. It's right there in organizer, after the "develop" prompt:

 OS Installed on My Name's i whatever: 6.0.1 (10A523)
 Xcode Supported iOS Versions Latest 5.1 (9B176)

 Clearly, I need to download the latest xCode, from here (according the original message): https://developer.apple.com/membercenter/index.action.

Unhelpfully, just the generic developer's menu. This confirms I need to got 4.5: To develop for iOS 6 you need xcode 4.5. Xcode 4.4.1 supports only 5.1 iOS version (Stack Overflow). Wow. Huge down, 1.8 Gig. That's a wrap for today.



No comments:

Post a Comment