Managing Multiple iPhone Developer Certificates

Back in the dark ages of iPhone development, being part of 2 separate iPhone development teams was problematic as Xcode didn’t deal with multiple developer certificates too well. Now Xcode will automatically select the right certificate (it took me awhile to find a reference).

 

Xcode.png

Each developer certificate now has a unique hex value at the end which lets you have 2 certificates for the same developer. However, until today, I never managed to get this to work properly. It turns out that in order to make things easier, instead of following Apple’s directions to create a certificate signing request, I control clicked on the private key I created for the first certificate and selected ‘Request a Certificate from a Certificate Authority With “iPhone Developer Private Key (Scott Gruby)’.

 

Keychain Access1.png

 

After that I was able to create my second certificate and have it associated with the same private key (I don’t think Xcode likes 2 different keys to have the same name). I’m not sure if this was absolutely necessary or if changes to how Apple generates certificates and changes to Xcode made things easier, but I’m not going to complain. I now can debug apps for multiple teams without having to change the bundle identifier and possibly make a mistake and check it into source control.

Easy version numbering in projects

 

When I start all of my projects, I do a few things to make version numbering easy.

First, I create a Defines.h file that looks something like this:

 

 

#ifdef INFO_PLIST
#define STRINGIFY(_x)        _x
#else
#define STRINGIFY(_x)      # _x
#endif

 

#define STRX(x) x

#define APP_VERSION_NUMBER STRINGIFY(1.0.0 b1) #define CF_BUNDLE_VERSION APP_VERSION_NUMBER

 

Then,  in the build settings, I set it up like this:

 

Xcode.png

 

Then my Info.plist has:

<key>CFBundleShortVersionString</key>

<string>APP_VERSION_NUMBER</string>

<key>CFBundleVersion</key>

<string>CF_BUNDLE_VERSION</string>

<key>CFBundleGetInfoString</key>

<string>AppName APP_VERSION_NUMBER, Copyright © 2010 Gruby Solutions</string>



 

 

So, I just change 1 value in Info.plist and the version number changes. Granted I could just change Info.plist for each build, but I’d have to change a few items. This becomes even more useful when projects have multiple components. In my projects that have multiple components, I like everything to have the same version number (these aren’t operating systems, so I can require an install of all components as once). With this technique, I just change the Defines.h and all the components get the same version number.

Some people change the APP_VERSION_NUMBER and CF_BUNDLE_VERSION to be different, but this mechanism still makes it easy to change the values.

 

First week of self-employment

Now that I’ve been self-employed for almost a week (Monday was my last day at my job), I feel like my life has changed a bit. There was nothing wrong with my old company or my old job, except that it just wasn’t for me. Prior to taking the job, I spent 5.5 years self-employed, so I really got used to the freedom and being my own boss. I feel like I’m back in control of my work as I have a schedule for one of my projects (or will soon) which will let me figure out when I need to work really hard and when I can work at a normal pace. In the world of software, most projects have schedules which helps in planning a workload. In the world of IT, there may be projects with schedules, but there always will be things that have to get done immediately (someone can’t get to a server or a computer doesn’t work; you can’t schedule those things in or delay fixing them).

Things seem to be much calmer as I start my day around 9 am and end around 5 pm; before when I got up, there seemed to always be something going on when I first checked my email at 7 am (also partly because almost everyone I worked with was 2 hours ahead). In addition, in this first week, I feel like I’m making progress towards a goal (the ship date for the current phase of my project).

This may be my “honeymoon” phase of being self-employed, so my excitement may wear down. However, I’m going to do my best to keep a positive attitude and make it so that my job doesn’t take over my life. I know that this isn’t easy to do, but it’s a goal that I’m making for myself.

If I ever decide to work for someone else, I need to look back on this post and evaluate if that is for me.

Review: Eye-Fi Explore X2

My 3 year old son loves playing with our digital camera which is fine, but I’m afraid that he’s going to accidentally delete pictures. I’ve tried giving him an old camera, but he wants to use the camera that mommy and daddy use. There are really only a few ways to prevent accidental erasure of the pictures. First, download all pictures immediately after taking them. This is a bit impractical. Second, put in a second memory card that he can use. A bit impractical and he likes to see the pictures we take. The last option is the Eye-Fi series of SD cards.

In decided to purchase the Eye-Fi Explore X2 and give it a go. It isn’t a cheap solution, but my hope was that it would be a fool proof way to keep all our digital memories.

Out of the box, the card was pretty easy to setup. However, I went to the Eye-Fi Web site and downloaded the software first which may have been a mistake. They offered 2 options; newer software and older software. I chose the older software as it looked like it would be a pure Mac application. I installed the software and basically it checked for an update and downloaded the newer software. After that, setup was pretty easy. I configured it to use my WiFi access point and also to use my MiFi in case we were out and about.

I snapped a few pictures and then fired up iPhoto. iPhoto imported the pictures and wow, that was cool. After some poking, I determined that the Eye-Fi software uses an undocumented feature of iPhoto to import the pictures (it drops them in an Auto Import folder in the iPhoto Library). I changed the settings to import to a folder as it would be more reliable (I think I lost a photo in the transfer process because of the Auto Import hack). My wife and son have been taking pictures and almost instantly I see a preview on my machine and the pictures get downloaded; very cool.

I haven’t had a chance to take pictures outside and then come home to see what happens, but that should happen this week.

The software on the Mac, frankly, is awful. Luckily it is only needed for setup. Instead of doing a web interface or even a full Mac application, they chose to do the background part as a Mac application and the foreground application as an Adobe Air application.

 

Eye-Fi Center.jpg

 

 

Pros

  • Easy to use and setup.
  • Automatic operation to upload locally or to sharing sites.
  • Automatic rollover of the card deletes old photos when card fills up.
  • Ability to control what goes to photo sharing site via camera’s “protect” feature.

Cons

  • Unable to work with Gallery 3 (OK, Gallery 3 isn’t done, yet, but I wanted to use it for sharing).
  • Uses a hack to integrate with iPhoto which could cause data loss if Apple removes the feature and/or iPhoto is open.
  • Expensive (about $100 for 8 GB vs. about $15 for a regular 8 GB card).
  • Geotagging may not always work especially if you’re not near WiFi access points.
  • Geotagging may present privacy concerns if you upload to a photo sharing site.
  • If you use a photo sharing site, the Eye-Fi uses their servers as a proxy. Paranoid people may not want their photos going through their servers.
  • If the company shuts down in the future, the online sharing feature will stop working.

Summary

While the Eye-Fi cards are not cheap, they are an excellent way to easily transfer photos from your camera to your computer or a photo sharing site. This will help prevent data loss and make it more convenient than plugging in a card. If you have some extra cash or are very concerned about losing the data on your camera, I’d definitely recommend getting one. However, just transferring the photos to your computer only partially solves the problem about preventing data loss. If you don’t backup your photos, you could still experience loss. On one podcast I heard recently, they recommend 3-2-1; 3 copies of important data, 2 different media, and 1 offsite backup. I do 3 and 1 as 2 different types of media is getting harder and harder with the amount of photos I have. Data backup is a topic for another post.

 

A stab at another VPS

Several weeks ago, the VPS (virtual private server) that I use to host my blog and Web site went down for more than 6 hours. The service, like most VPS services, has a 99%+ uptime guarantee. Well, the uptime guarantee is kind of useless as the site is still down and the few bucks credit I got aren’t really worth much. Their support folks didn’t get back to me until the end of the outage and then gave some excuse that they were short staffed. By the time the site had come back up, I had already signed up with another VPS and restored my site (I have scripts on the VPS that backup nightly and then everyday, my Mac syncs down the backups). The whole setup process takes me about 2 hours as my VPS isn’t all that complicated.

So, now I’m trying out 123Systems Solutions on their second level VPS (25 GB disk space, 1 TB traffic, 512 MB RAM burstable to 1 GB). I found a discount code and brought the price to just over $10/month. Like the last one, they offer an uptime guarantee. This one has only been around for a few months, so we’ll see. Worst case is I move my VPS again; a little time consuming, but definitely not the end of the world. They have been quite responsive when I submitted a ticket and have communicated when they’d be short staffed. I’m also impressed with their control panel to manage it. However, their reverse DNS doesn’t seem to work properly. Oh well, not the end of the world.

My new office

Yesterday, my wife asked if I wanted to come with her to pick up our son that was spending the day at my parents. I asked her what time and she said that she’d leave around 4pm. Hmmm, I had a 4 pm meeting. I said “sure”, but she’d have to drive. 4 pm came around, I got on my phone call, turned on my Sprint MiFi, switched my Mac over to the MiFi’s network and was all set.

I hopped in the car, put the MiFi on the dash and my wife drove. The hard part was seeing my screen, so I had to put a jacket over the screen.

No one was the wiser about my mobile office! We didn’t encounter any dead cell spots, so the call went flawlessly and I was connected for the entire 30 minute or so ride.

I’ve had a MiFi for about a year, but for some reason I didn’t use it much. Now that I’m paying for my own service, I feel compelled to use it to its fullest.

Leaving logging statements in production code

I’ve written in the past about how I think that leaving logging code in production or release builds is bad practice. While I have no objections to being able to turn debug logging on or off to help troubleshoot problems in the field, it shouldn’t be on by default. Recently I’ve read conflicting views about leaving NSLog statements in code. One really good solution is:

 


#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"%s %@:(%d) %@", __PRETTY_FUNCTION__,\
[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__,\
[NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif

(I’ve modified the solution a little.)

Then in Xcode’s build settings, add a preprocessor macro for DEBUG_MODE. Presto, NSLog statements never make it into shipping code. If you need to turn the logging on and off, I like to write the statements out to a file so that they don’t pollute Console and it makes it easier for users to send me logs. Furthermore, I’ve seen NSLog cause crashes because the developer passed the wrong arguments or did something like NSLog(@”test: %d, self). This type of bug should be fixed, but using the above logging would prevent the crash in production code.

 

Tenets of software development

Lately I’ve been talking to people about some development projects and I keep repeating my 2 tenets of software development. The first is from Brian Hall of Mark/Space. He used to say

Shipping is a feature.

While this sounds quite simple in nature, it’s pretty important to any product. Not only is shipping a feature, I think it is the number 1 feature. My second tenet is something that I came up with when more and more features were added to a project and QA kept finding issues.

Software is never done; it’s just shipped.

Now you’re probably saying that these are either obvious or just plain idiotic. Anyone that has done software development for anything length of time has to agree with the second. How many bug fix releases have you done? I may strive to be a perfectionist, but I’m also a realist. You can spend forever making software perfect, but you’ll never reach the end.

It’s important, in my opinion, for anyone in a software project to be on the same page with these tenets. Without these, you can’t ship a product which means you can’t make money. There aren’t that many companies that I know of that can survive without shipping products and making money (OK, maybe there are companies that only do government contracts and keep taking money without shipping something that works.)

Doing what you love to do

When I was in college, I had no idea what I was going to do. I was in a general engineering program at Harvey Mudd College which was going to prepare me to be a “general engineer”. Would a company hire me when I didn’t have a speciality? I had no idea and really didn’t think about it much. During the winter break of my junior year, I wrote a program called NotifyMail which you could consider “push notification” to alert me of new email. Way back then I was addicted to email and wanted to know instantly when I had email. This was the turning point in defining my career.

For the next 14 years, I wrote a lot of software. I wrote so much code that engineers called me “Dash” from the Incredibles! I lost track of the number of products I worked on, but do have a collection of product boxes and brochures on shelves in my office. 18 months ago, I was tired of writing code, so I accepted my current position where I’d write very little, if any, code, but would do more R&D as well as run IT for a small company.

In my spare time for the last 6 months or so, I’ve been working on a coding project that really got me to think about what I love to do. It turns out that I love to write code. There is something about the challenge of writing code as well as the freedom in writing code that really keeps me going. Sometimes I get obsessed with writing code so much that I can’t sleep trying to solve a problem. Also, being able to say “yeah, I wrote that” and getting feedback from users is pretty cool.

After much personal reflection, I came to the conclusion that I needed to go back to writing code and get out of the world of IT. Last week I tendered my resignation and I’ll soon be self-employed again doing contract software development focusing on Macintosh and iPhone/iPad applications. This change, of course, does not come lightly, but I believe it is the right move.

If you have a need for a highly talented (and modest :-)) software engineer, please let me know.

I can’t believe I didn’t sign up sooner!

A friend pointed me to Dropbox the other day to transfer PDFs to my iPad. I’m not sure why I didn’t sign up earlier. It’s free for up to 2 GB and it works so seamlessly. It’s actually easier to use than dragging and dropping files across my network; just place the file in the Dropbox folder on one machine and it appears on the other machine almost instantly. It really couldn’t be any easier.

I’ve reviewed their specs and they say it is secure where even their employees can’t view files. I haven’t read anything to the contrary, but who knows. Will I put my accounting data on it? No. Will I put temp files that I need to move around on it? Sure.

Give it a try and see if it can work for you.