Michael Kayeasked me “how he can he handle things like Localizable.strings and InfoPlist.strings. You can’t have two copies of these files and there is no info.plist setting I can use to target the correct file with a different name. Plus how would one handle different Default.png for each target?” Answer to this question is very simple, you have to write a script which should run before compiling your application.

So in this tutorial I am going to write a Script file which will run before compiling and that script will overrite existing files and only copies required files for that build. If you didnt read first part of this tutorial, then I recommend you to read the first part before you continue reading this tutorial (Same Xcode Project Create Multiple Products for iPhone).

So in this tutorial I am going to handle different Default.png file for both lite and full versions, also I add different background screens for different versions. Out put will look like this

Take the old code which I used in first tutorial (you can grab old code from here). Open it in Xcode and drag two images files in to Xcode (just like we add images to the project), one is Default.png and other one is PakistanFlag.png (In my case both Image are same). Also place images folder anywhere you like, I place it inside my project (Note: please do not drag it in Xcode project)

Open your HelloWorldViewController.xib file and place UIImageView component (320×480 px) and provide “PakistanFlag.png” file as image. Map it to your HelloWorldViewController.h file.

Once we set-up everything for Xcode now its time to write a script for it. As we have two targets files inside Xcode project we have to do these steps for every target (Best solution would be you add a script to one target and then duplicate it). Please follow the following steps to write a script:

In Script TextArea write script file name with path of the script as well, which in my case is “./runtimeScript”

Close this window and expand the target “HelloWorld” you will see a “Run Script” folder at the end. Move it to top in hiracry so that it runs before anything else compile.

Please repeat step 1,2,3 for “HelloWorldLite” target as well. We will be using same script file for both tragets.

Now its time to write a script for your project. Right click on “Resource” and select >Add > New File. Select “Other” from the panel and then select “Shell Script”. Click Next and give it a name you write in step two (runtimeScript) and do not select any target because we do not want to copy this file in our binary project.

My name is Adeem M Basraa. I am a software engineer from Lahore, PK. I’ve been involved in software development for nearly 4 years, with the last 1 year focused on application development for mobile devices (iPhone & Android).

It’s interesting to see how to use a script. Though I don’t quite get the reason for it. For my Luckywheel and LuckyWheel Lite I have the same project. The resources specific to Lite I have in a sub folder. Now all I needed to do is assign the regular info.plist and Default.png to the regular target and for the Lite target deselect those and instead select info.plist and Default.png from the sub folder. No scripting necessary. I still use a script though, to cut out only 10 questions per language file for the Lite version.

Hi Adeeb,
I there a way to do conditional inclusion of frameworks too? Something like MessageUI.framework inclusion for 3.0 and not for 2.2.1? Maybe I’m missing out something very basic in the settings?
Thanks

Great tutorial! The supplied demo worked great on Xcode 4 but when I it on a new project I get.

Shell script invocation error

/Users/…../myApp.build/Script-6568843B13FEA39D009E8DD8.sh: line 2: ./runtimeScript: No such file or directory

It doesn’t even appear to run my runtimeScript.h file as I removed any of the cp statements just so I know it wasn’t to do with the images being in the wrong folders etc. I followed the instructions exactly and am experienced with Xcode 4.