Multi-Target
I’m not as methodical and organized with my iPhone development as I am at my day job. My version control system is Time Machine, I have PNG images scattered all over my desktop, and up until recently I was maintaining separate projects for my full and lite versions of each product. Why? Probably a bit of laziness and probably a bit of not thinking the time investment was worth the payoff. It’s quite possible this was a little more difficult to do in Xcode 3 as well, but I never attempted it.
So while I was gutting Tramp Stamp to remove OpenFeint and go Game Center exclusively, I decided to merge the projects. The first thing I did was launch FileMerge to compare the 2 projects and see what I was dealing with. If you haven’t used it, it’s probably one of the most useful hidden tools on my Mac next to Automator. The comparison showed only a handful of files and images were different.
The next thing I did was duplicate my target and change the PRODUCT NAME. Then I added a define (LITE_VERSION) to the compiler options. I then merged the source files that had differences using #ifdef to handle the two streams of logic. I then added _lite to all the relevant image names and changed/split any code that referenced them. Wallah! A few hours later and I had both projects running and merged into 1 more manageable project.
I did run across one problem where the simulator refused to launch the lite version. It would crash in main telling me that the app was already running. A little searching and I found out that a reboot would fix it (I had already tried to kill zombie processes). Sure enough it did. Seems to be attributed to the way the process ends some times. If I use the stop debug button, it seems to be better than shutting down the app from the simulator.
I am now doing the same with my other 3 apps. Up until this point my build settings had been intermixed between the project and target ones. Now I’m understanding the target settings a lot better and can change the appropriate ones. This probably won’t make me any more money or give me any more exposure in the app store, but somehow this gives me satisfaction and makes the thought off adding any future enhancements a whole lot more palatable.
Ok… now I really should get busy on my never-ending project. See ya next time!
Comments
8 Responses to “Multi-Target”
Leave a Reply





“If I use the stop debug button, it seems to be better than shutting down the app from the simulator”
Sure it does. If you press the home button on the simulator, the app does not quit, it just goes to background, just like on the real device. So of course it continues to run
I recomend you to use GIT or other SCM.
Having only 1 build with multi-target is good. But you should go even further and having just 1 target for both lite and full. If you haven’t a startup file (like a text file or an ini file) you should add one. Simply tell if that file if your App is Lite or Not. Instead of having #ifdef LITE_VERSION, change this to if (IsAppInLiteMode) or whatever. Job done, just one App that is acting differently depending on it’s parameter. This is DEFINITELY the way to go. My engine is cross platfrom (PC/Mac/iOS) and this is extremely usefull for my computer build. The same App could be my demo on my website or a version for a portal (they behave sightly differently but I don’t have to re-compile to make a build for a specif portal or whatever…).
JC
@Ovogame What? But don’t you need separate info.plist files, icons, bundle ids, possibly different code signing? Seems like this is exactly what apple is intending with multiple targets.
Ok,
in my example, I was mainly talking about how cool it is on PC/Mac.
“hy? Probably a bit of laziness and probably a bit of not thinking the time investment was worth the payoff. It’s quite possible this was a little more difficult to do in Xcode 3 as well, but I never attempted it.”
I think you pretty much nailed it for me that I probably should’ve admitted on the site. I think laziness played a huge factor in not learning how to use multiple targets.
[...] a previous blog entry I had mentioned that I combined my Full and Lite versions of each of my apps into one XCode project [...]
[...] a previous blog entry I had mentioned that I combined my Full and Lite versions of each of my apps into one XCode project [...]