Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create two projects, using the same source with a different App Name and info.plist?

Tags:

xcode

ios

Actually, my iOS App contains multiples version in the same project, changed with a #define in a Static Class.

Example:

#import "AppVersion.h"

//...

if (MYAPP_VERSION == kMyAppVersionFree) {
   //Limited features
}
else if (MYAPP_VERSION == kMyAppVersionFull) {
   //No limit !
}

Each time I want to compile, I have to edit my code to change the #define MYAPP_VERSION, and change the project name, to be able to release a MyApp and "MyApp Free" executables...

Is it possible to define this as a "compilation variable"? I don't want to have to edit my code each time I want to compile 2 versions

How can I create 2 projects, using exactly the same source (many classes) but with a different App Name and a different info.plist (and, relative to previous question, different "compilation variables")?

I'm asking for a different info.plist because my "Free version" doesn't support iTunes file sharing, but my "Full version" does...

Any idea? How do you manage versions in your projects?

like image 242
ingham Avatar asked Apr 14 '11 09:04

ingham


People also ask

What is info plist in Xcode?

Xcode supplies an information property list file when you create a project from a template, as described in Create a project. By default, Xcode names this file Info. plist and adds it to your project as a source file that you can edit. Xcode creates one information property list for each target in the project folder.


1 Answers

You need to define targets for your various versions.

Click on the root of your project (the blue xcode icon). You will see your project settings in a table. On the left hand side you will see a "TARGETS" heading, with one child, the name of your project.

You can right click the target and duplicate it. Once you have a duplicate, you can rename it and then configure it's settings separately. One of the project settings are the GCC Preprocessor values. You can define LITE or FULL variables based on your target and then use #ifdefs in your code to do conditional compilation.

You can add different pList files for different targets. Just right click on the pList files and include or exclude the files for each target.

like image 155
RedBlueThing Avatar answered Oct 04 '22 22:10

RedBlueThing