Free and Pro versions

:  ~ 1 min read

For my first 2 games I had a project for the Pro version and another project for the Free version, and, as everyone knows, that's a huge pain to maintain.

So, at first I created this:

#define kFreeVersion ([[[NSBundle mainBundle] infoDictionary]\
[@"CFBundleIdentifier"] isEqualToString:@"com.rolandleth.appnamefree"])

and added a warning in the App Delegate:

#warning Reminder: Don't forget to check this on every release!
if (kFreeVersion) {
    // do stuff for the free version
}

But this implied, as the #warning suggests, to never forget about manually changing the bundle ID at every release. So searching I went and I found this, then this.

Pretty basic stuff, which I never thought about. I combined the 2 approaches, and now I have 2 targets, but use the above macro instead because I think #ifdefs make the code look ugly.

Combined with this script (I have Run script only when installing checked):

VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
NEWSUBVERSION2=`echo $VERSIONNUM | awk -F "." '{print $2}'`
NEWSUBVERSION3=`echo $VERSIONNUM | awk -F "." '{print $3}'`
NEWSUBVERSION3=$(($NEWSUBVERSION3 + 1))
NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 ".'$NEWSUBVERSION2'" ".'$NEWSUBVERSION3'" }'`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $NEWVERSIONSTRING" "$INFOPLIST_FILE"

makes releasing 2 versions of an app much easier than what I was used to.

Edit, 10 minutes later: Well, I had to switch to the #ifdef approach, because I wanted to remove all the ad related frameworks from the paid version, so I don't have any troubles with the approval. Oh well...