Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two versions of iOS app - Free and Paid - how to conditionally change project ID in Xcode?

Tags:

xcode

ios

iphone

I have my app with ID com.mydomain.AppName which is a paid version.

I decided to introduce free version as well, and through my code I easily add ads/remove some functionality with simple #defined/#ifdef business.

However, I do need my app ID to be different for free version. How do I do this conditionally (i.e. #ifdef FREE_VERSION ... etc.) for my app?

like image 503
alexeypro Avatar asked Nov 02 '11 04:11

alexeypro


1 Answers

This question was answered in a previous post

The basic idea is that you create two targets and then either use #ifdefs or create separate files to control the content in the two targets. Creating another target is dead simple. Just right-click on your existing target and duplicate it. Give it the name that you want for the free app.

In your case, you'll probably want to have different icons for the Free and Paid game, so create two icon folders—one called Free-Icons and the other called Paid-Icons. Put them in the project folder and when importing attach them to one of the targets.

I duplicated the original Info.plist and Prefix.pch files and gave them different names but you could use the same names, just put them in different folders. You'll need to adjust the build settings for each target to reflect the new names.

You might also have less content in the free app. Just select the sounds and pictures that are only in the paid app and in the inspector mark the Target Membership as just the paid app.

You'll also need to edit your schemes as so that you can build two versions. I just finished doing this for a project that I'm working on and it took about two hours from start to finish to find everything that needed changed. I'm guessing I could add another version in about 15 minutes now that I know what I'm doing.

This way of doing things is way better than duplicating the code or swapping the content out in one code base because you can easily switch back and forth between targets to make sure everything works when you make changes.

like image 139
JScarry Avatar answered Oct 19 '22 22:10

JScarry