CocoaPods Keys (Permalink)

Orta released a clever new CocoaPods plug-in to manage keys, application secrets and the like. Pretty much everything you don't want to check into your repository.

After you install the plug-in, storing the keys in the OS X Keychain and accessing them in your code becomes dead simple:

You can save keys on a per-project basis by running the command:

$ pod keys set KEY VALUE

After the next pod install or pod update keys will add a new Objective-C class to your Pods xcworkspace.

#import "ORAppDelegate.h"
#import <CocoaPods-Keys/MyApplicationKeys.h>
#import <ARAnalytics/ARAnalytics.h>

@implementation ORAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    MyApplicationKeys *keys = [[MyApplicationKeys alloc] init];
    [ARAnalytics setupWithAnalytics:@{
        ARGoogleAnalyticsID : keys.analyticsToken;
    }];
}

@end

I think this is a great example of what can be built on top of the CocoaPods infrastructure. That being said, I assume that someone will write a similar but independent script soon.

Note that it depends on the upcoming CocoaPods 0.34.

Posted in ❤ing