Nicolas Goles

Code & Randomness

Automating Xcode 4 Template Generation

Hello again!,

It’s a nice day in the French Riviera ( or Côte d’azur )!, it’s been more work than pleasure here, but I guess life is good :D

In this iDevBlogADay post I will describe how we managed to automate our needs for Xcode 4 template generation. We wanted to automate it because we use a little Engine here at Gando Games (GG), and project templates where more or less a must for us. I have been reading everywhere about project templates in Xcode 4, and I must admit that it’s a rather obscure process. In order to understand a bit more, I followed the Boreal’s Kiss “A minimal project template for Xcode 4” article. After reading it, I realized that since our toolset was changing quite often, we where going to need to somehow automate the generation of Xcode 4 Templates for our internal engine, plus I thought it was a cool thing to do :)

That lead me to extend a very basic Cocos2d tool called Template Generator. This tool is just a simple python script which can build a very basic TemplateInfo.plist, which is basically a .plist file used to describe an Xcode 4 Template, this was great but wasn’t enough for my needs. After having found that tool, I contacted Ricardo Quesada (Cocos2d Lead Developer) and asked him if I could just take that tool and start a new “mini project” from there, he was very cool about it so I started hacking the script right away.

The results can be found in Github under the MIT license under the name of “Xcode 4 Template Generator”, I think the short description is self explanatory:

The Xcode 4 template generator, is a simple script written in Python to aid in the rather obscure process of creating Xcode 4 templates. As you may already be aware, Xcode 4 templates are very different from Xcode 3 templates, so taking a look at Boreal’s Kiss “A minimal project template for Xcode 4” is recommended. In that article you will find a lot of information about what is currently known about the new Template System.

I thought about this tool as a helper script for a meta script ran my Continuous Integration server, this meta script is the one in charge of actually building the full Xcode 4 template, I present you that script here:

WARNING: My Python is really noobish, sorry for that… ;)

So, that’s basically it more or less. I hope that from that script you’re able to extrapolate what you need in order to automate your Xcode 4 Template generation. As a last thing to say, the Xcode 4 Template Generator is far from complete, and should have issues… if you happen to need a patch feel free to open an issue in Github… or you want to collaborate I will totally welcome any kind of help, pull requests etc.

Until the next one!