Integrating InAppSettingsKit with Storyboard, UITabBarController, and ARC

I love the concept of InAppSettingsKit.  While it’s possible to make your own settings view and hook up all your own buttons, I like the simplicity of installing a “plugin” — just copy over the files, hook it up to a view, and be done with it.

I’m using the iOS 5 SDK with a Storyboarded app, using a Tab Bar, and I was able to integrate it pretty simply after a trip to Google got me on the right track:

1) Created my Settings.bundle, including NSUserDefaultsDidChangeNotification observers as described in the Apple Settings bundle documentation.  The AppPrefs sample app helped here (specifically with the observers).

2) Copied the InAppSettingsKit directories (not the sample app) into my project.

3) Made sure I had all the necessary Apple frameworks:

  • MessageUI Framework
  • UIKit Framework
  • CoreGraphics Framework
  • Foundation Framework

MessageUI was the only one I needed to add.  Project > Targets > MyApp > Build Phases > Link Binary With Libraries and click the + icon to add any that are missing.

Before adding it, I was getting this horrible error:

missing required architecture i386 in file
Undefined symbols:
  "_OBJC_CLASS_$_MFMailComposeViewController"

The nature of the error message was completely alien to me, but — again — thank you, Internet.

4) In Storyboard editor, I added a new Navigation Controller and Table View Controller.
4a) I deleted the view controller that came along for the ride when I dragged the new navigation controller to my storyboard.
4b) I linked the navigation controller to my tab bar controller, then linked the navigation controller to the table view controller (control+click and drag).
4c) I selected the Table View in the table view controller and changed the Style of the prototype content to “Grouped”.
4d) I changed the controller class to IASKAppSettingsViewController.

Et voila, it compiled and worked. With this method I didn’t need to add any custom controllers or views; just the InAppSettingsKit files and linked a new table view to the main IASK controller.

Also worth noting: since I’m using ARC in my project, I opted for an ARC-compatible fork of InAppSettingsKit. See the ticket on Github. I used tibr’s fork.

Related:

Advertisements

11 thoughts on “Integrating InAppSettingsKit with Storyboard, UITabBarController, and ARC

  1. I had been battling for days to get the InAppSettingsKit to work properly. I found this article and decided to start from scratch following your instructions. I decided to use the latest official branch of code on Github and suppress ARC just for IASK. It all worked – genius, thanks for taking the time to write this blog!

    (Just a side on how I suppressed ARC for the IASK part of my project only this is what I did after adding the IASK files to my Xcode project:
    1. Go to project navigator and select your project -> Targets -> Build Phases.
    2. Expand the Compile Sources group.
    3. Select the first InAppSettingsKit file – easy to spot as file names all start with IASK… – double-click the file and a little pup box will appear.
    4. Enter the following into the pop-up box: -fno-objc-arc and then click Done.
    5. Repeat steps 3 and 4 for all IASK files this will suppress ARC on only these files in your project.)

    Like

    1. Glad it helped! Thanks for the heads up on suppressing ARC for InAppSettingsKits. I was being optimistic that the ARC fork would get merged into the master branch, but I really doubt that will happen. For the new app I'm working on I'm planning on suppressing ARC as you suggested.

      BTW, drop me a line when your app gets approved. I'm curious to see what you're building. 🙂

      Like

    2. You can also select all the concerned files (cmd + click) and then press enter, it will show the pop-up where you can enter the flag : -fno-objc-arc for all selected files 😉

      Like

    1. Nope, as far as I can tell you just have to guess/assume what the native back buttons look like. You can implement your own from scratch, including the method to pop your controller. If there's a better way I don't know it.

      Like

  2. This worked great. Thank you. I burned up a couple of days trying to figure this out. I'm wonder though with this approach how do you define your delegates? Would I have to create my own class that subclasses IASK?

    Like

    1. Glad it helped. Not sure what you're referring to when you ask "how do you define your delegates?" I haven't needed to assign IASK as a delegate to anything yet, although my use of IASK has been pretty simple so far.

      When I've needed to customize something, I've done as you said — subclassed the IASK controller and assigned that to my view, then customized my custom subclass as needed.

      Like

  3. Thank you angel Gabriel’s. You saved my day.

    Just wanted to add a comment that when you link navigation controller to the table view controller select segue as “Root View Controller”

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s