How much time and effort would you say a typical developer puts into making a game? I can tell you from experience that if you are just one person, it can very well take months upon months to come up with a good game and maybe close to a year to come up with a great game.
If you’ve ever developed a great game or even just an average game, you should also know the value of having a free Lite Version for your paid Full Version. If your game requires a purchase of even .99 cents you should make sure that you provide users with a Lite / Trial Version of your game that they don’t have to pay for. The purpose of having a Lite Version is so that they can try out your game with the other reason being of course marketing.
Everyone will download the free version over the paid version so what you have to do is make sure that your free version leaves with some sort of cliff hanger, something that will make the user want to purchase your full version to continue playing. If you’ve ever watched a season of any TV show, you’ll see that at the end of the season it leaves you with a cliff hanger and by the time the new season comes on, you can hardly contain yourself. This is what your game should do, it should make the user curious about what comes next, what will happen to the hero at the end of the story???
Anyways, enough of that… let’s get on with the tutorial. I will be showing you how to implement within Xcode a really quick and easy method to keep your Full and Lite versions separate but together…
An overview of what we will be doing is outlined in the steps below:
- Start a new XCode Project
- Duplicate the current Target
- Rename the Duplicated Target
- Rename the Duplicated Info.plist File
- Change the Icons in the Duplicated Info.plist file to use the Lite Version Icons
- Change the Bundle Identifier to match with the bundle identifier from Apple for the Lite Version
- Edit Build Properties of the Duplicated Target
- Add C / C++ Compiler Flags
- Change the Product Name
- Change the name of the Info.plist file to the name of the Duplicated Info.plist File
- Add Logic to code to separate features of Lite and Full version.
As you can see, in only a few steps we can set up our app’s environment to make it very easy to have a lite and full version within the same project and be able to build them separately. In the tutorial listed below I will be covering what I have outlined above with a lot more details and screen shots.
Let’s Start by Opening Xcode and starting a new project. I’ll be starting a new Cocos2D project as you can see in the Screen shot below and I’ll be calling it MyGame.
After you’ve started a new project and Xcode has finished loading you will need to look on the bottom left side of the window. You’ll need to locate and expand the Targets group and then right-click and click on duplicate. See the screen shots below for an example.
This will make a duplicate of the MyGame Target, and will also create a duplicate of the Info.plist file. Next we will need to rename the duplication of the MyGame Target. I’m going to use the name MyGameLite. We will also need to rename the duplicated Info.plist file, and for simplicity I just named mine InfoLite.plist, to keep a standard naming convention. You can see some example screenshots below.
You’ll also notice that in the above screen shot to the right clicking the Build drop down will now show you 2 Targets, one for MyGame and one for MyGameLite.
Next we need to edit some of the Build settings for the MyGameLite Target. If its not already expanded, expand the Targets group and then right click on the MyGameLite target and from the pop-up menu, click on Get Info. An example screen shot is shown below.
After clicking on Get Info, you will be presented with a dialog box that has a number of tabs across the top of it. The tab we are interested in is the build tab. Go ahead and click on the build tab and ensure that in the Configurations drop down, that All Configurations is selected, then in the Search window type Product Name. If you are following this tutorial to the T, then your product name should say MyGame. We’ll need to change that to MyGameLite. To change it, just double-click on MyGame and then make your change and click on OK. See example screen shots below.
What we are interested in here are the “Other C Flags” and the “Other C++ Flags”. Your results may differ from mine depending if you already have some compiler flags setup. Double click on the empty space next to Other C Flags and you will get a dialog window pop up. In this window you will need to type the following without quotes: “-DLITE_VER” and then click on OK. This should set both the “Other C Flags” and the “Other C++ Flags” See screen shots below for examples.
I know that the screen shots are a little small but if you click on them you can see the images a little bigger. There is one more setting that we need to change in the Build settings and that is to specify the name of our Info.plist file. Currently it is still defined as Info.plist but we want to set it to InfoLite.plist so that the build settings match.
Go ahead and type Info.plist File and locate the “Info.plist File” string which should read “Info Copy.plist” or something similar. Change this string to InfoLite.plist.
You are now done with Build settings and you can safely close the Build Settings Dialog. See below for some example screen shots for renaming Info Copy.plist
Now we just need to make a few minor changes to our InfoLite.plist file and then we can start modifying some code. Locate the InfoLite.plist file, usually in the left column under the Resources group and click on it. You should see the values of the InfoLite.plist file listed in your preview window on the bottom right.
We need to change the Icon and the Bundle Identifier. To do this you simply edit each with the proper names. For instance, I used IconLite.png for my icon file and used com.domain.mygamelite for the bundle identifier.
The bundle ID’s for the Lite and Full version of your game must be different in order for Apple to recognize that they are 2 separate applications and so that you don’t run into any issues when using the uploader.
That’s pretty much it for setting up the environment. It seems like a lengthy task, but once you’ve done it a few times, it should only take you about 5 min or so to get your environment setup for multiple apps within one project.
So lets go ahead and do some coding so I can show you how to use the environment we just setup to differentiate your code from being for your Lite version or for your Full version.
Within any file in your Xcode project, I am using a Cocos2D template so I will be using HelloWorldScene.m, all you have to do is place the following code:
#ifdef LITE_VER //- Code that should be executed if the build target is set to MyGameLite #else //- Code that should be executed if the build target is set to MyGame #endif
What the above code does is, it checks for compiler flags of LITE_VER, remember when we set the Other C and C++ Flags? Well this is where they get used. Anything between
will get compiled if the Lite version build target is selected while everything between
will not. You should be able to figure out how to move forward from here. I suggest that this be the first thing you do before starting the development of your game. The game I am currently working on is about 45% finished and it just now occurred to me that I need to start thinking about a Lite version. Even if you think that you will be making a free app, go ahead and make a Lite version anyways, you never know, and you might change your mind later.
Believe me, this is much easier to implement when you haven’t already spent months writing thousands of lines of code
So… I’m hoping that this was able to help someone, and if anyone needs any help or has any questions, feel free to leave me a comment.. Happy Developing
So… you’ve installed the latest SDK and XCode from Apple’s developer site only to find out that the only base SDK’s you are left to develop with are 3.2 and 4.0. What about if you have an iPhone 2G as your only development device? The iPhone 2G only goes up to iOS 3.1.3 and if you are stuck with the lowest base SDK of 3.2, you will not be able to push your apps to your iPhone.
This is exactly what happened to me. I downloaded the beta SDK for the 4.0 iOS when it came out. Little did I know that when you install that, it removes all SDK’s prior to 3.2.
Luckily for us, Apple is kind enough to keep previous versions of Xcode and their SDK’s available for download. Here is a list of available downloads.
- iPhone SDK 2.2.1
- iPhone SDK 3.0 with Xcode 3.1.3 – Leopard
- iPhone SDK 3.0 with Xcode 3.2 – Snow Leopard
- iPhone SDK 3.1 with Xcode 3.1.4 – Leopard
- iPhone SDK 3.1 with Xcode 3.2.1 – Snow Leopard
- iPhone SDK 3.1.2 with Xcode 3.1.4 – Leopard
- iPhone SDK 3.1.2 with Xcode 3.2.1 – Snow Leopard
- iPhone SDK 3.1.3 with Xcode 3.1.4 – Leopard
- iPhone SDK 3.1.3 with Xcode 3.2.1 – Snow Leopard
- iPhone SDK 3.2 Beta 4 with Xcode 3.2.2 – Snow Leopard
- iPhone SDK 3.2 Final with Xcode 3.2.2 – Snow Leopard
- iPhone SDK 4 Final with Xcode 3.2.3 – Snow Leopard
- iPhone SDK 4.0.1 with Xcode 3.2.3 – Snow Leopard
- iPhone SDK 4.0.2 with Xcode 3.2.3 – Snow Leopard
- iPhone SDK 4.1 with Xcode 3.2.4 – Snow Leopard
You have to be logged into the Apple developer site http://developer.apple.com to download the above listed SDK’s. I downloaded the 3.1.3 Snow Leopard SDK since I already have 3.2 and 4.0 and 3.1.3 includes all of the above mentioned SDK’s as well as 2.0 and 2.1.
Once you’ve downloaded the SDK of your choice it should be in the form of a DMG, go ahead and mount that and open up the resulting volume. You should get something that looks like the image below.
At this point you will need to open up the Packages folder rather then running the installer because all we want are the SDK’s. When you open up the Packages folder scroll down a bit until you see the SDK’s. You should see something similar to the screen shot below.
You’ll see that there are device SDK’s and simulator SDK’s. You don’t have to install the simulator SDK’s if you don’t want to because all we are really after here is to be able to push our apps to an iPhone with an iOS earlier then 3.2. Double click on one of the iPhone SDK’s and you will be presented with an installer screen like the one below.
Click on Continue and and you will get to the next screen similar to the one in the screen shot below
On this screen you need to click on the drive you want to install the SDK to. In most cases it will be your primary Hard Drive. If you have your Developer tools installed on a different drive then you should select that one instead. Next you need to click on Choose Folder and you will be presented with a Choose Folder dialog similar to the screen shot below.
If you are like me and installed Xcode in the default location then you should have a developer folder in the root of your Hard Drive. Click on the Developer folder and then click choose. You will see a screen similar to the one below.
You can verify on this screen that you’ve selected the proper folder. It should have a blue circle around the Hard Drive and if you’ve picked the Developer folder it should say the following on the bottom “You have chosen to install this software in the folder Developer on the disk Macintosh HD. Click Continue and you will be presented with a screen similar to the below screen shot.
This is just a confirmation screen, from here you just need to click on Install. You may be prompted with a password screen. Enter your password to continue with the installation. You should see a screen similar to the one below.
Depending on the SDK you are installing this part can take up to 5 minutes to complete. When the installation is done you will be presented with a screen similar to the one below.
Click on close. At this time your installation of the SDK is complete. You can verify that the SDK installed successfully by launching Xcode. Once Xcode is launched open an existing project or start a new one and go to Project -> Project Settings. You should see a screen similar to the below screen shot.
Click on the drop down towards the bottom where you can choose your base SDK and if all went well you should see a screen similar to the below depending on which SDK you installed.
Pick your SDK of choice and enjoy. Hopefully this tutorial has helped someone with their project. I spent many hours the other night researching how I could install older version SDK’s and once I found an easy method I thought I would share it with the rest of the world. If for some reason you don’t see your SDK listed here then it may have been installed in the wrong folder. If you can’t get it working feel free to ask me for help. I’m always willing to help out a fellow developer.