iPhone dev 3: Steven and 3.0

May 13, 2009

Last time I blogged about iPhone development, it was like nails on a chalkboard to Steven, a friend and coworker of mine and the author of Routesy San Fransisco.  When I got into work that day, he called over to me: “Joe, next time you work on your iPhone development, maybe I should help.”  This drew some laughter from several other coworkers, who it turns out also read my blog.

I took him up on this generous request.  He’s writing a chapter for a book on iphone development (sorry, I can’t find a link to it).  After he helped me get into a state where I can start developing – which involved a bunch of steps I no longer remember, sorry again – we walked through the first part of his chapter, and he gave me an electronic copy of it to take home and walk through further.  I did some objective C programming, as well.  It has some funny features.  It uses reference counting to persist objects, but you have to handle the references manually.  Also, it uses this weird square-bracket notation for calling member functions on instances: [MyInstance doThing].  If there’s a single parameter, it’s like this: [MyInstance doThing:Parameter].  If there are two parameters, it’s even weirder: [MyInstance doThing:FirstParameter secondParameterName:ActualSecondParameter].  The internal name of the second parameter comes right before a colon, same as the name of the method itself.  I’m sure this comes naturally after you’ve been coding objective C for a while, but it’s confusing still.

I won’t be getting any practice on this today, since I’m busy downloading the iPhone 3.0 SDK, which is now mandatory.  Apple sent out an email to all developers saying that all apps will now be tested against 3.0.  This really only means they have to be forwards-compatible, but there’s no reason to bother with 2.2 when I don’t know what will and won’t be.  Instead, I’m using my 2 hours of personal project time to update all my blogs and research quaternions for my GDC notes series.


Step 2 part 2: I suck at setup

April 21, 2009

I went back to the project portal I had so much trouble finding yesterday, and resumed the walkthrough for getting my security key / certificate set up. The instructions told me to go to a specific page to download my certificate, but that page told me I didn’t even have one. I had to submit another request, and get another certificate going. It seems like Apple considers me a Team of One (Be All That You Can Be!), so I had to sign up both as the team lead and as a team member. Also, I had to approve my team member certificate, since I’m the team administrator. Kinda made me feel powerful. Apple also had to approve me separately both as team admin and as team member, so I had to wait for that, but as yesterday, it was almost immediate.

I moved on to getting my phone into development mode. By now I’m pretty good at finding the tutorials for how to do things on apple’s site, but that doesn’t mean that they’re any good! The instructions start with:

  • Download the iPhone OS Disk Image (.dmg) from the iPhone Dev Center for the Apple device you are using.

They don’t say where you can do that, and I couldn’t find it. Before I looked around for solutions, I decided to try building my Hello World app to see if it gets through the errors I had yesterday. Success! I got a different error:

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

Sounds like xCode has a problem with my 3GI still.  So, back to getting my iPhone into developer mode! At least Apple’s keeping me on track. Sure enough, the first google result for “Download the iPhone OS Disk Image (.dmg) from the iPhone Dev Center for the Apple device you are using”  was a forum where someone else had the same problem. The first few solutions on the forum direct you to no-longer-existent links to the download.  The solution I tried: tell iTunes to “restore” my phone, which, as it turns out, means “crank for 45 minutes and leave the phone in the same state.”  It deleted everything off there, maybe installed the OS I want, and is now re-uploading all my music on there.  We’re waiting on that right now.  It looked like a long block, so I decided to use the time for today’s blog post.

Yesterday, the great Steven Peterson read my blog and had a lot of helpful suggestions for how to get started.  He’s got a delicious page that, hilariously, I can’t link you to here because I stored the URL in a note on my iPhone.

Oh, hey!  It finished.  Huh.  It restored all my media files but threw away all my apps, including the one that was tracking my diet.  And it turns out I lost the link, so we’ll have to wait and see whether Steven reads my blog again today.  For now, let’s see whether I can build my Hello World app.

Steven, and guy who commented on my blog yesterday, I understand that I don’t have to do this step right now 🙂  In fact, if I switch xCode to use the simulator instead of my 3G, I get 3 other compile-time errors.  I’ll deal with them later.  For now I really want to know that I have all the pieces ready to go.

Anyway, no, it appears the iPhone restore was in vain.  Same error.  Let’s ask the Google.  Damnit; none of those solutions are going to work for me, and I’m out of time.  Be back tomorrow.

iPhone App development step 2: Keychain

April 21, 2009

So I paid my $99 and got approved by Apple. Many months passed during which I never had a free weekend. This week, my roommate and I decided we’d get up 2 hours early every day and work on a personal project during those two hours, so for the last hour and a half I’ve finally done some iPhone development. Well, setup for it.

During the last few months, I’ve been asking some other iPhone developers I know how to get started, and gotten some tips; a couple different ideas for how to test-drive an app, ways to get started, and such. None of them mattered this morning; I ended the morning being blocked by something completely unforeseen.

I already downloaded and installed the 2.2.1 SDK, not really knowing what that means. I guess it’s a text editor, build system, and standard library for the iPhone. I found xCode, the editor, on my computer, and walked through apple’s Hello World iPhone tutorial. It involved the creation of a project and the retyping of some code without understanding it (the language is objective C), then a build and a run. The build failed with this message:

CodeSign error: Code Signing Identity ‘iPhone Developer’ does not match any code-signing certificate in your keychain. Once added to the keychain, touch a file or clean the project to continue.

Sounded like Apple’s SDK won’t even build your project for you locally unless it has some authentication. I didn’t know what keychain was, but it sounds like Pageant. I googled this error and saw lots of forums threads I didn’t understand, then looked around apple’s website. It said that I needed an “iPhone Development Certificate,” which I wrongly assumed I already had. It turns out that what I have is membership in the iPhone Developer Program, which is different. What that gets me, according to apple, is the ability to apply for an “iPhone Development Certificate”, which is what the SDK requires. To apply for an iPhone Development Certificate, I needed to create a Certificate (some kind of crypto key, created by an apple program called Keychain) and submit it in a Certificate Request.

The instructions for creating a Certificate were only hinted at, not explained, in the developer section of the apple website. They said I needed to go to the “iPhone Developer Program Portal” to actually get instructions and submit the certificate request. When I tried to log into the portal, it walked me through the developer signup steps (including the $99 payment, again) – turns out this was a bad cookie horking my session. At the end of the signup, the developer webpage told me I’m already a developer, and wanted me to sign out. I signed out and back in, and lo, I had a link to the “iPhone Developer Program Portal”!

In it were wrong instructions for how to create a Certificate Request. In particular, they assumed the wrong location for the program (KeyChain) that creates the security keys, one of which I need to submit. (Also, I learned that OS version numbers have magic names. “Leopard” is the one Apple expects me to have. I don’t know what jungle cat my mac mini is actually running.) At Dusty’s suggestion, I used the finder to launch KeyChain, and from there the walk-through worked fine. I created a key and submitted it with a Certificate Request. At that point, I was blocked until Apple approved the request, so I dropped development for the day and started writing this blog entry.

About halfway through typing this up, Apple approved my Certificate Request, so I can get started again. Unfortunately, my 2 hours for today are almost up, so I’ll have to pick up here tomorrow morning. See you then!

iPhone App development step 1: Giving Apple $100

April 21, 2009


This post is from February, merged from my other (now defunct) blog

Steps -2 and -1 were buying a mac mini and a 16GB 3GI. Accomplished. Worth the money on their own, actually! Step 0 was coming up with an idea for an app. This was hard to do. Most of the good app ideas have already been done. However, considering what kind of apps are succeeding, maybe I’m wrong about what’s a good idea! Nonetheless, I have an idea.

Today was when I made what I consider my first real step towards making my app: paying Apple $100. I signed up at their site, filled out their survey, and maybe they’ll let me try to make them some money. If not, I hear they’ll give my money back. It’s a bit underhanded, if you ask me – them taking my money when I apply and giving it back only when they reject me. It makes me feel like I wasn’t charged, but they get to float the money, and it then motivates them to delay rejections. Hmph.

So, the next steps, not necessarily in this order, are going to be:

  • Read up on objective C (begun)
  • Read up on the iPhone platform
  • Set up a version control system on my fancy new mac

None of them are blocked on Apple accepting me as an iPhone developer. The ones that are AFAIK:

  • Convert my iPhone into developer mode
  • Set up Apple’s development environment
  • Set up a testing environment (TDD FTW!)

I’ll get started on these and resolve which ones are actually blocked by Apple. More posts to follow, as well as reports on how the learning is going.