Wednesday, 18 March 2009

iPhone OS 3.0 Beta

Well, I've taken the plunge and installed the iPhone OS 3.0 beta on my iPhone 3G.

... it's a one way trip just in case you didn't read bullet point 3 of the iPhone OS 3.0 beta pre-installation advisory notes.

I'm guessing this was a popular download as Apple's iPhone Dev Center site initially failed under the load.

Here's the cool stuff so far:
  • Cut Copy Paste (it works well)
  • Forwarding of text messages (which we had that around xmas)
  • Landscape for mail, notes and the new messages app (SMS++)
  • Global search (wish it had some filter icons eg apps only)
  • Synchronisation of notes (but only to Apple Mail and Mobile Me)
Most painful experience was having to reorganise my 150+ icons :-(

Thursday, 12 February 2009

Using Xcode Targets for Adhoc iTunes Artwork

By creating multiple Xcode targets you can adjust what files are included in each target.

eg iTunesArtwork for adhoc users or testers

As the iTunesArtwork file only works for adhoc builds you want to exclude it from debug and release builds.

To create an Adhoc target which includes your iTunesArtwork  file you need to:
  • Create a new Adhoc target
  • Add your iTunesArtwork file to your project
  • Change the target memberships for your iTunesArtwork
Step by Step:
  1. Duplicate the primary target (right click -> Duplicate)
  2. Rename the new target to Adhoc
  3. Add your iTunesArtwork file to your project as described here
  4. Change the target memberships for your iTunesArtwork file to Adhoc only using:
    Select Target -> right click -> Get Info -> Targets
    (make sure only Adhoc is selected)
Once you've made these changes you can explore the Target build phases. The iTunesArtwork file should only appear in Copy Bundle Resources for the Adhoc target.

It may be useful to have matching targets and configurations for each type of build eg
  • Debug
  • Adhoc
  • Release 
When changing the build type set both the active configuration and active target.

Other uses for multiple targets include:
  • Different icons for Debug / Adhoc / Release builds
  • Incrementing build numbers only for Adhoc / Release builds

Identifying the Current Xcode Configuration

The easiest way to identify the current configuration in code is by creating a preprocessor macro under your Xcode project build settings.

Step by step:
  1. Project menu -> Edit Project Settings -> Build tab
  2. Select All Configurations
  3. Scroll down to GCC 4.0 - Preprocessing
  4. Add the following to Preprocessor Macros Not Used in Precompiled Headers:

Assuming you have Debug, Adhoc and Release configurations, this will generate preprocessor macros for each configuration. ie
In your code you can now use something like:

NSLog(@"Debug message");

#if defined (CONFIGURATION_Debug) || defined (CONFIGURATION_Adhoc)
NSLog( @"Warning message");