Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 0.0.1
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (47 sloc) 2.944 kb

GroundControl

Remote configuration for iOS

Break free of the two-week tyranny of the App Store approval process!

Many developers don't realize that they are allowed to remotely control the behavior of their app (provided that the application isn't downloading any new code).

GroundControl gives you a dead-simple way to remotely configure your app, allowing you to add things like feature flags, impromptu A/B tests, or a simple "message of the day".

It's built on top of AFNetworking, and provides a single category on NSUserDefaults (just add #import "NSUserDefaults+GroundControl.h" to the top of any file you want to use it in).

Client Code

  NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
  [[NSUserDefaults standardUserDefaults] registerDefaultsWithURL:URL];

...or if you need callbacks for success/failure, and prefer not to listen for a NSUserDefaultsDidChangeNotification:

  NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
  [[NSUserDefaults standardUserDefaults] registerDefaultsWithURL:URL
                                                         success:^(NSDictionary *defaults) { ... }
                                                         failure:^(NSError *error) { ... }
  ];

...or if you need to use an HTTP method other than GET, or need to set any special headers, specify an NSURLRequest:

  NSURL *URL = [NSURL URLWithString:@"http://example.com/defaults.plist"];
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
  [[NSUserDefaults standardUserDefaults] registerDefaultsWithURLRequest:URL
                                                                success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSDictionary *defaults) { ... }
                                                                failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) { ... }
  ];

Server Code

GroundControl asynchronously downloads and reads a remote plist file. This could be a static file or served dynamically. Either way, since property lists aren't especially fun to write by hand, you can generate and serve one rather easily using the plist and sinatra gems (full working version can be found in example/server):

require 'sinatra'
require 'plist'

get '/defaults.plist' do
  content_type 'application/x-plist'

  {
    'Greeting' => "Hello, World",
    'Price' => 4.20,
    'FeatureXIsLaunched' => true
  }.to_plist
end

Creators

Mattt Thompson
@mattt

License

GroundControl is available under the MIT license. See the LICENSE file for more info.

Jump to Line
Something went wrong with that request. Please try again.