Tuesday June 14, 2011

✦ WWDC 2011 Followup

WWDC was great; my first time there. Fun, nostalgic, and exciting. Yes, I waited in line at 3:30am for the keynote.1 No, I’m not doing that again. I’m a practical fan. :)

I spent most of my lab time with the Xcode devs. They gave me some tips and tricks and cleared up lots of confusion I’ve had as the tools evolved. I’ll be rolling out some posts about them soon (git submodules!), but I figured I’d throw out a few quickies.

Build Configurations

You no longer need an “Ad Hoc” build configuration. Remember way back when the walk-through documentation made you duplicate the “Release” build config and rename it “Ad Hoc”? And then the only thing you changed in that build config was the provisioning profile? No longer. Sharing or submitting an archive gives you a chance to re-sign the application. So, I just set my “Release” build config to use my ad hoc profile and deleted my “Ad Hoc” build config that I had set up from the Xcode 3 days.

Generating .ipa Files From Shell Scripts

I wanted to automatically generate .ipa files for ad hoc distribution whenever I build. A shell script to do so would look like this:

SIGNING_IDENTITY="..."
PROVISIONING_PROFILE="..."

xcrun -sdk iphoneos PackageApplication "$CODESIGNING_FOLDER_PATH" \
  -o "ad_hoc_file.ipa" \
  --sign "$SIGNING_IDENTITY" \
  --embed "$PROVISIONING_PROFILE"

# $CODESIGNING_FOLDER_PATH is provided by Xcode during build time.
# It's the final build path to the `.app` bundle

# $SIGNING_IDENTITY is the text identifier of your signing certificate.
# You can list then yourself by running
#  `security find-identity -p codesigning -v`
# and use the text in double quotes.

# $PROVISIONING_PROFILE is the actual `.mobileprovision` file you get
# from the Developer Provisioning Portal.

With this command, you get an .ipa file written wherever you point the -o option. I put this as a “Run Script” build phase so that any time I build the application, it automatically packages it up for me. That way, I’ll never forget to export an up-to-date .ipa before running my TestFlight submission script.

But, I’m bummed that I have to hard code the signing identity and provisioning profile path into the script. I checked in the environment variables exported by the Xcode build process but didn’t find anything I could use to inject them here. I’ll keep digging, but this is at least a good start.2

inside the Xcode project’s build environment. PackageApplication is one of many binaries used by Xcode for some of it’s magic. As of right now, it’s located in /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin along with some other goodies. Could be a good place to explore.

Oh, The Things To Talk About…

There are so many good things coming in iOS 5. Apple has some pretty forward thinking ideas about Objective-C. I still think they should consider MacRuby more seriously, and they may do so in the future, but for now they’re moving in interesting directions with the tools at hand.

  1. #251 in line.

  2. For the curious xcrun is a command that runs the given binaries