Creating a custom plist

Sometimes you will need to modify the plist file that is automatically created when you build an iOS standalone.

You might need to do this to

  • Add a permission
  • Set a message to used in the app when requesting permission to a service
  • ...

Property list(plist) files are XML files so can be edited in a text editor or the plist editor in Xcode.

For more information on plist files see this Apple Developer guide.

In this example we will see how to modify a plist to add a key and change the message displayed when the app requests access to location services.

Setting up the Standalone

Once you have created your stack open the Standalone Application Settings, go to the iOS pane and ensure you have set all the requirements you need. In this case we want the app to access the location 'When in Use'.

Save the Standalone

Now choose "Save as Standalone Application" from the File Menu and open the folder containing the app bundle. Right click the app bundle and choose "Show Package Contents".

Open the Info.plist file

Open the Info.plist file in your preferred text editor ready to make some changes.

Modifying a key

Find the NSLocationWhenInUseUsageDescription key in the file. This key is automatically created by the Standalone Builder because we selected the 'When in Use' option for location services.

The first thing we are going to do is to provide a more descriptive string for this key, Apple sometimes require non-default descriptions so this type of modification can be common.

Update the <string> value for the NSLocationWhenInUseUsageDescription key with something more descriptive and relevant for your app.

<key>NSLocationWhenInUseUsageDescription</key><string>This application requires access to Location Services when in use to find local restaurants</string>

Adding a key

In some cases you might also want to add keys to the plist file. For example in iOS 11+ Apple added a requirement to include an NSLocationAlwaysAndWhenInUseUsageDescription key so we'll add that here.

Add the key and string to your plist file, remember to include a descriptive string.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>This application requires access to Location Services to find local restaurants</string>

The Standalone Builder will now add this key, we are just using it as an example here.

Save the modified plist

Now we have a modified plist we need to rebuild our standalone and include it at the building stage. Modifying the plist after building the app will cause the app to be rejected.

Save your modified plist somewhere outside the app bundle, but leave it named "Info.plist"

Include the modified plist in your app

Now you need to include the modified plist when building your standalone

  • Open the Standalone Application Settings
  • Include the Info.plist file in the Copy Files pane
  • Save the standalone

Now check the plist file in your new standalone. You will see that the modified plist is included.

Including a custom plist will override any changes you make in the iOS standalone settings so if you make any changes to your settings remember to update your custom plist or repeat this process to create a new plist file with all the settings you need included.

0 Comments

Add your comment

E-Mail me when someone replies to this comment