Pages

Wednesday, August 28, 2013

Same Xcode Project Create Multiple Products

Some times you need to build two versions of your iPhone application(i.e lite and full version) from the same Xcode project. So one way is to make two copies of your Xcode project and manage both independently which is not a good way. Because when you have to change a little in your iPhone application, you have to change in both copies of your Xcode projects. So its not easily manageable for anyone to change a line of code in both codes of one application. So following this tutorial, you can make different applications from one source Xcode project!

Xcode is really a good IDE which provide lot of features. Everyday I come across to know more about Xcode features while building iPhone applications. So today I am going to share another most important feature of Xcode which helps you when you are thinking to create two iPhone application but with same project. So theme of this tutorial is to, create one application in Xcode and generator two builds(binary) form same code. In other words, you don’t have to manage two copies of your application. Just create one application and generator two copies of build(binary) files for apple store.
So let just start without going any further discussion. What I will do in this tutorial, create a project in Xcode and place three buttons on controller view. One button will display for lite version and one button will display on full version.

So lets start:



1. Create a “View-Based Application” project in Xcode and named it “MultipleProducts”

2. In your ViewController.h file write the following code for linking with Interface builder
IBOutlet UIButton *buttonOne;
IBOutlet UIButton *buttonTwo;

3. Open ViewController.xib file in interface builder and place two buttons on the view. Now select two buttons and set hidden property to true.

4. Now map those buttons with ViewController class.

5. Open ViewController.m file and write down following code in viewDidLoad method ( I will explain this code later):
#ifdef LITEVERSION
buttonOne.hidden = NO;
#endif
#ifdef FULLVERSION
buttonTwo.hidden = NO;
#endif

6. Duplicate your target MultipleProducts and  Rename the duplicate file(HelloWorld copy) to MultipleProductsLite (see figure)



7. Now you will see “MultipleProductsLite-Info.plist” and “MultipleProductsLite-Info copy.plist” in your Resources folder. Rename “MultipleProductsLite-Info copy.plist” to “MultipleProductsLite-Info.plist” . To check if everything goes right, select “MultipleProductsLite” application from target and clicked on “info” from Xcode and chosse MultipleProductsLite-Info.plist for this target.




8. Last step, clicked on "build setting” and type “OTHER_CFLAGS” in “Setting” column and type -DLITEVERSION in value column. Close info window.



9. Now select “MultipleProducts” form target  and right clicked on it to select “build setting” and type “OTHER_CFLAGS” in “Setting” column and type -DFULLVERSION in value column.

Now its time to build full version for MultipleProducts,  Now run the project and see the result.

Now to build for lite version of the MultipleProducts, select the MultipleProducts copy and run the project and see result



Keep Coding…

No comments:

Post a Comment