I usually create a Settings entry for my apps to include an Acknowledgements screen, where I display info about the Open Source libraries used in the app. This article will show you how to create one, with two base elements:

  • Toggle Switch – which I will use to turn something ON or OFF
  • Child Pane – which I will use to display the Acknowledgements screen

The end product will look like this in iOS 7:

First Screen in the iOS Settings app

First Screen in the iOS Settings app

Second Screen in the iOS Settings app

Second Screen in the iOS Settings app




Now, on to the tutorial!

First, we create the Settings Bundle.

  1. In Xcode, choose File->File… (or press Command+N)
  2. Select Settings Bundle

    Create Settings Bundle from Xcode

    Create Settings Bundle from Xcode

  3. Then save it inside your project (I usually put it inside <ProjectName>/Resources).

Verify if your Settings.bundle file has been created correctly.
It should contain the following:

Before we proceed with the next step, delete first the all Preference Items in Root.plist (delete Item 0, Item 1, …, Item 3).
In this tutorial, we will start from scratch.

Next, open Root.plist. We will create the first group in our Settings page.
This group will include the title of the group (we will name it “Tutorial”).

  • Add a new Preference Item by clicking on the “+” button on the right
  • Change Item 0 to “Group”
  • Change the value of Title to “Tutorial”

After creating the group, we will now create the Toggle Switch that will be under the “Tutorial” group.

  • Add a new Preference Item (Collapse Item 0->Right click on Item 0->Add Row)
  • Change the new item (Item 1) to “Toggle Switch”
  • Change the value of Title to “Show tutorial on launch” (you can name this with whatever you want)
  • Change the value of Identifier to “SettingsShowTutorialOnLaunch” (this will be used the key when getting the current value using NSUserDefaults, e.g.
    [[NSUserDefaults standardUserDefaults] boolForKey:@"SettingsShowTutorialOnLaunch"])
  • Change the default value to YES or NO, depending on your needs. In my case, I will set it to YES.

You can try to run your app if you like. After running your app, go to Settings (in your iOS device or simulator), then verify if it looks like the following:

Toggle Switch in the Settings app

Toggle Switch in the Settings app

Now, we will create the second group. We will name it “Acknowledgements”.

  • Add a new Preference Item (Collapse Item 1->Right click on Item 1->Add Row)
  • Change Item 2 to “Group”
  • Change the value of Title to “Acknowledgements”

After creating the second group, we will now create the Child Pane that will be under the “Acknowledgements” group.

  • Add a new Preference Item (Collapse Item 2->Right click on Item 2->Add Row)
  • Change Item 2 to “Group”
  • Change the value of Type to “Child Pane”
  • Change the value of Title “Acknowledgements” (or with whatever you like)
  • Add a new item under Item 3 by clicking on the “+” button beside “Title”
  • Select the new item as “Filename”
  • Change the value of Filename”Acknowledgements” (or with whatever filename you like)

We are now done editing Root.plist!
You can now run your app to verify if the items have been added, but note that the Child Pane will not be displayed yet.
Only the group title will be added for now. See image below as reference to what your Root.plist should look like.

Final Root Plist for Settings Bundle

Root Plist for Settings Bundle

To generate the files related to the licenses, I use the script in the following post: http://stackoverflow.com/questions/6428353/best-way-to-add-license-section-to-ios-settings-bundle/6453507#6453507
In this article, I will add an acknowledgement entry for “EAIntroView”, which can be found here: https://github.com/ealeksandrov/EAIntroView

  • Create a “Licenses” folder. I usually place it in “<ProjectName>/Resources/Licenses”. The Settings.bundle file is in “<ProjectName>/Resources/”.
  • Place the script inside the newly created folder.
  • For each acknowledgement you want to add, create a *.license file inside the folder. In my case, I will create a “EAIntroView.license” file.
  • For each created file, format it according to the SO post above. In my case, I will remove the manual line breaks and replace them with a space. Also, I will put the name of the library at the top, before the Copyright sentence. This is my formatted file:
  • If you target iOS 7, use “FooterText” instead (as stated in the SO post).
  • Run the script!

You can verify if the script worked correctly if the following files have been created inside Settings.bundle:

  • Acknowledgements.plist
  • en.lproj/Acknowledgements.strings

Run the app! Your screens should now look like the end product:

First Screen in the iOS Settings app

First Screen in the iOS Settings app

Second Screen in the iOS Settings app

Second Screen in the iOS Settings app




That’s it! Was that easy for you?
Please leave a comment below.

References:
https://developer.apple.com/Library/ios/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html
http://stackoverflow.com/questions/6428353/best-way-to-add-license-section-to-ios-settings-bundle/6453507#6453507

Happy Goals for iOS

Happy Goals for iOS

Want an app to help you track and achieve your goals, without the complex stuff, saving you from headaches? Checkout Happy Goals - Habits & Goals Tracker now in the App Store! Happy Goals has been featured in the App Store in over 32 countries. Start now, better late than never!

 

Thank you!

%d bloggers like this: