Objective-C keychain wrapper for iOS and Mac OS X. Completely unit tested using Kiwi.
Objective-C Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
RFKeychain.xcodeproj Update project to XCTest, new cocoapods version Sep 27, 2014
RFKeychain.xcworkspace
RFKeychainTests
.gitignore
LICENSE
Podfile Update Kiwi pod, add source command to podfile as recommended Sep 27, 2014
Podfile.lock
README.md
RFKeychain.h Add methods that use an access group Sep 27, 2014
RFKeychain.m Add methods that use an access group Sep 27, 2014
RFKeychain.podspec bump version to 0.3 Nov 6, 2014

README.md

RFKeychain

RFKeychain is an Objective-C keychain wrapper for iOS and Mac OS X. It is only tested on iOS 6 and Mac OS X 10.8.

Why another xxKeychain?

Other libraries I found seemed unnecessarily complex and I wanted to get a better understanding of the keychain. By building it completely test-driven, there should be nothing in the code that is not necessary to pass the tests which keeps the code short and clean. Tests are written in BDD-style syntax for Kiwi. Therefore, it should be stable and a good example for people getting started with unit testing on iOS.

Installation

CocoaPods

pod 'RFKeychain', '~> 0.3'

Manual

  • Copy RFKeychain.[h|m] into your project
  • Add Security.framework to your target

Usage

The following methods are currently implemented

+ (BOOL)setPassword:(NSString *)password
            account:(NSString *)account
            service:(NSString *)service;
+ (NSString *)passwordForAccount:(NSString *)account
                         service:(NSString *)service;
+ (BOOL)deletePasswordForAccount:(NSString *)account
                         service:(NSString *)service;

There are also methods to use iOS 7 keychain sharing which expect an additional accessGroup that you have specified in your app's entitlements

+ (BOOL)setPassword:(NSString *)password
            account:(NSString *)account
            service:(NSString *)service
        accessGroup:(NSString *)accessGroup;
+ (NSString *)passwordForAccount:(NSString *)account
                         service:(NSString *)service
                     accessGroup:(NSString *)accessGroup;
+ (BOOL)deletePasswordForAccount:(NSString *)account
                         service:(NSString *)service
                     accessGroup:(NSString *)accessGroup;

If you want to know more about the methods, you can find their behaviour in the RFKeychainSpec.

Tests

To run the tests, you first need to install Kiwi by running pod install (assuming you have CocoaPods installed, otherwise you need to do that first, obviously). The included project is configured to run on Mac OS X. However, you could easily create an iOS project that runs the tests.

Status

RFKeychain is pretty trivial right now, I'll add features and better error handling as I need them myself. Feel free to help out but please always add tests.