Tuesday, April 29, 2014

Creating multiple apps from one project

If you are planning to publishing multiple apps from one project (for example, light version and premium version), this will be the article that can help you out.

1. Click Manage Scheme.

2. Untick the "autocreate schemes" option. By unchecking this option, you can assign a proper scheme name.

3. Click on the project Targets. Two finger click on the "taget item" that you want to duplicate.

4. A new plist file will be added to the project. Rename the plist file to whatever you want. In our case, we use "premium version". Do the same for the "Bundle display name" and also "Bundle identifier".

  Note: you need two app ID. One for the light version and another for premium version.

5. Goto the project targets again. Rename the target to "premium". In Build Settings, search for "Product name" and update it as well.

6. Search "plist" in Build Settings and change it to the appropriate plist file name.

7. Click on the "scheme" and choose New Scheme.

8. Choose the "premium" from the target and then key in "premium" as the scheme name.

9. The final step will be setup the preprocessor macros. You need to edit both Debug and the Release.

  • For premium version, add "IS_PREMIUM_VERSION".
  • For light version, add "IS_LIGHT_VERSION".

10. In the coding, you have to do this:

 
     #ifdef IS_PREMIUM_VERSION
         lbl.text = @"this is premium Verison";
     #else
         lbl.text = @"this is Light version";
     #endif

Saturday, April 26, 2014

Find the user document directory in Simulator

One day, I want to backup my Sqlite database created inside the Simulator to my MacBook data directory and I was wondering if this is possible. Yes, it is possible. The files that was created in Simulator is physically located in your MacBook.

You can find the physical directory with the codes below:

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];

Sample output:

  /Users/{your Macbook user name}/Library/Application Support/iPhone Simulator/7.1/Applications/{random number}/Documents