During a recent iOS development I needed to distribute a 3rd-party license agreement with my app. Apps such as iBooks, Keynote, Facebook (and many many more) utilise the Settings app to not only display user-editable preferences, but also license agreements and acknowledgements.
Adding your app into Settings is a simple case of modifying your Settings.bundle (if your XCode project doesn’t include a Settings.bundle file, simply right-click your project -> New File -> select Resource (under iOS) -> then on the right, Select Settings.bundle template (when creating the file make sure you keep the default file name ‘Settings’).
Once you’ve created a Settings.bundle subsequent builds of your app will add an app specific menu (including app icon and title) to the Settings app. If you’ve created your Settings.bundle from the supplied template (as above) your initial app specific settings menu will contain some example elements (a title, toggle and slider).
To add our own information into our Settings menu, we need to edit the Root.plist file contained inside Settings.bundle. Within XCode, expand the Settings.bundle item and you should see the following file structure:
A .bundle is a package, not a directory, in Finder you can view and work with the contents of your Settings.bundle by right-clicking Settings.bundle and selecting Show Package Contents.
Root.plist is the file we will edit to create our menu structure, while Root.strings contains any strings we wish to insert.
Initially our Root.plist will contain the default template items:
As you can see from the above screenshot, this template contains a Group of items (i.e. Grouped UITableView) containing a TextField, a Toggle Switch and a Slider. For the purpose of this guide, you can now remove each item.
Creating an Acknowledgements section
At this point we have a choice; do it all manually or set-up and use a convenience script. I prefer the latter, it means we can easily add to or remove particular licenses during the lifespan of our app.
The following solution is taken from an excellent answer on Stack Overflow – http://stackoverflow.com/a/6453507
Rather than repeat the contents of that post, I thought I would simply include a zip of my licenses folder and Settings.bundle. I had a couple of glitches to begin with, all of which we due to line-breaks mid-paragraph.
As it happens, this particular project was being developed using Appcelerator’s Titanium framework. Those of you who have used Titamium in the past will know that it includes it’s own build process, prior to triggering an XCode build. In order to make use of a Settings.bundle (using the latest version of Titanium SDK), you need to create the following folder structure Project Root -> modules -> iphone -> Settings.bundle. Like so:
Changes to your bundle will be picked up on each subsequent build in Titanium Studio.