Remote configuration for iOS
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).
MajorTom 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 inpsired by GroundControl, and provides a single category on NSUserDefaults
.
UserDefaults().registerDefaultsWithURL(url: URL(string:"https://theprogressapp.com/wtw/defaults.plist")!)```
...or if you need callbacks for success/failure, and prefer not to listen for a NSUserDefaultsDidChangeNotification
:
UserDefaults().registerDefaultsWithURL(url: URL(string:"https://theprogressapp.com/wtw/defaults.plist")!, success: { (response, dictionary) in
print(response.debugDescription)
print(dictionary.debugDescription)
}) { (response) in
print(response.debugDescription)
}
MajorTom asynchronously downloads and reads a remote plist file. This could be a static file or generated dynamically, like in the following examples:
require 'sinatra'
require 'plist'
get '/defaults.plist' do
content_type 'application/x-plist'
{
'Greeting' => "Hello, World",
'Price' => 4.20,
'FeatureXIsLaunched' => true
}.to_plist
end
from django.http import HttpResponse
import plistlib
def property_list(request):
plist = {
'Greeting': "Hello, World",
'Price': 4.20,
'FeatureXIsLaunched': True,
'Status': 1
}
return HttpResponse(plistlib.writePlistToString(plist))
var plist = require('plist'),
express = require('express')
var host = "127.0.0.1"
var port = 8080
var app = express()
app.get("/", function(request, response) {
response.send(plist.build(
{
'Greeting': "Hello, World",
'Price': 4.20,
'FeatureXIsLaunched': true,
'Status': 1
}
).toString())
})
app.listen(port, host)
Or, simply create a plist file in Xcode and upload it to your webserver :)
Lewis Smith
MajorTom is available under the MIT license. See the LICENSE file for more info.