Update:Nov 7th 2011:
Get the latest ARC compatible template from the Attachments section

With XCode 4, Apple has made some changes to the template subsystem as such none of the old templates that worked on XCode 3 will work automatically. After spending a couple of hours, I managed to figure out the differences and fortunately, the new template subsystem is more cleaner than XCode 3. The Singleton template I created last year is now migrated to support XCode 4.

XCode 3 vs XCode 4 Template Changes

Some good news here. Back in the ages of XCode 3, you have to manually edit a plist when you install multiple templates from different sources. For example, if you install the  NSOperationTemplate by Jeff Lamarche and then install the Singleton template by me, you will end up overwriting the template list plist and at anytime only the lastly installed template will be shown on the XCode New File dialog. With XCode 4, Apple has made some changes that, every template is independent and doesn’t really have to overwrite any files that was installed with XCode. This means, when you install multiple templates or when you do upgrades, you don’t have to manually edit any files or re-install templates.

Download these files from the attachments section and extract them from Terminal using the command
The new Xcode 4.3 gets installed into /Applications by default and you have to overwrite the contents of the package file which requires admin privileges. So you should type in your password after entering this command.

sudo unzip SingletonTemplateARC.zip -d /Applications/Xcode.app/Contents/
sudo unzip NSOperationTemplate.zip -d /Applications/Xcode.app/Contents/

If you are still on Xcode 4.2 (I don’t understand why anyone would be using that though), enter the following commands instead.

unzip SingletonTemplateARC.zip -d /
unzip NSOperation.zip -d /

Once it’s extracted, open XCode 4 and add a new file to your project. The new file dialog will now show two new icons as shown below.

Xcode 4 with new templates

XCode 4 new file dialog with new templates



Update:Nov 7th 2011:
Singleton Template for XCode 4 (ARC Compatible)
As a bonus, I’ve also migrated Jeff Lamarche’s NSOperation template to XCode 4. I believe his code is in public domain and free for derivate work and re-distribution. So get it for XCode 4 here.
NSOperation Subclass Template for XCode 4
Leave a comment or tweet this if you like.


Follow me on Twitter

  • Pingback: XCode Tip: Objective-C Singleton Class Template | MK Blog()

  • Pingback: Xcode 4 Migration at Under The Bridge()

  • Sorry I don’t understand. I download your attachment and get a very deeply nested set of folders. How exactly do I find the .zip files to unzip?

  • Pingback: Singleton Template for XCode4 : Code()

  • Forrest

     I like the template file, it is easy to install by simple copying. Just wonder any more common used templates ?

  • Pingback: Objective-C Singleton template()

  • Ikonau

    this would be a silly question and easily answered but how do i add my own properties in here? it doens’t show any samples (commented out or otherwise)?

    Thanks :)

  • Pingback: Singleton ain’t bad after all | MKBlog()

  • Hpdave1984

    i installed ios 5.0, bt i dont get the option… please provide the help

  • Rob5408

    I know for Xcode 3 the suggested location for templates was in your own template folder (~/Library/Developer/Xcode/Templates/File Templates) as Xcode updates used to overwrite Xcode’s own template folders. I’m not sure if this is the case anymore, but the location I suggested will work just in case…

  • Thank you for your template. And I’d like to suggest one modification release method.
    (void) release got a warning on Xcode 4.2. When replace (void) to (oneway void), warning disappeared.

  • Tomas

    Mugunth, your singleton template is great. However Xcode 4.3 is giving me a warning on the release method definition which should be (oneway void)release instead of (void)release

    • MugunthKumar

      I thought I fixed this. Give me sometime. I’ll upload the newer version.

  • Pingback: XCode Templates | Sascha-Matthias Kulawik()