Tuesday, April 13, 2010

The Missing Universal iPad/iPhone App Template

The ideal way to package your app for the iPhone and iPad is to create a single "Universal" App. This style of app allows you to customize your interface for each device while reusing common code. In addition, a single Universal app is best, so you don't confuse users with the requirement to download multiple versions of your app.

XCode 3.2 does not include an ideal template for creating a Navigation-based Universal App. Apple has said that iPad apps should respect all device orientations. Meaning if you turn the device, the app should redisplay in the new orientation.

Getting the Navigation Bar and Orientation working correctly can be a little tricky to accomplish if you don't start out with a good template. It's fairly simple once you understand the required elements, but that can be a painful process. I created this template to save time. The template is also configured for Core Data. If demand exists, I will create a version without Core Data.

The template is hosted at github. The following commands will install the template in your local XCode templates folder.


mkdir -p "$HOME/Library/Application Support/Developer/Shared/XCode/Project Templates/My Templates"

cd "$HOME/Library/Application Support/Developer/Shared/XCode/Project Templates/My Templates"

git clone git://github.com/benellingson/Universal-Navigation-based-Application.git

rm -rf "Universal-Navigation-based-Application/.git"




Once the template is installed it will appear under "My Templates" when you create a New Project.

Universal Navigation-based Application

If you find this helpful or have suggestions, please leave a comment.

7 comments:

  1. Hi

    when i run the third command i face the following issue :
    Permission to benellingson/Universal-Navigation-based-Application denied to...
    Can you please tell what i need to solve this.

    ReplyDelete
  2. @Narinder: benellingson should be replaced in the paths with your username.

    ReplyDelete
  3. @Narinder: I misread your question. The corrected answer is to clone from the read-only URL:
    http://github.com/benellingson/Universal-Navigation-based-Application.git

    So the corrected syntax would be:
    git clone http://github.com/benellingson/Universal-Navigation-based-Application.git

    ReplyDelete
  4. Thanks Matthew! I have updated the instructions.

    ReplyDelete
  5. Hi Ben,

    nice application template!

    A couple of suggestions for improvement (things I've adjusted after using the template):

    It would be nice if both RootViewController_Pad and RootViewController_Phone derive from a common RootViewController_Shared; there are undoubtedly things that the 2 controllers can share.

    I've also made the following modification to both AppDelegates:

    [super application:applicationication didFinishLaunchingWithOptions:launchOptions];

    right after the // Override point comment marker; and added an empty method returning just YES to AppDelegate_Shared.m. I use this so I have a common place where I can bootstrap models that are common to both iPad and iPhone.

    ReplyDelete
  6. Hi Ivo,

    Thanks for the feedback! Next time I get a chance to hack on this.. I'll implement the RootViewController_Shared suggestion.

    I think there are a lot of simple improvements/options that should be made available for app templates.

    - Ben

    ReplyDelete