An iOS Developer’s (Mostly) Open Source Toolchest

One benefit of a big platform like iOS is that developers can choose from many tools and technologies. Below are our selections for my current project. Most of them are available via CocoaPods.

Objective-C

We’re using Objective-C for two main reasons:

  • Existing expertise within Atomic.
  • A mature and robust ecosystem. (At the time of writing, StackOverflow has ~210k Objective-c questions)

Alternatives: Swift; other languages via platform abstraction layers like Xamarin, RubyMotion, Phonegap, etc.

ReactiveCocoa

ReactiveCocoa brings Functional Reactive Programming to Objective-C, and is a favorite around AO. It’s very well suited for asynchronous work like UI and network interaction, helping us keep the majority of our code lazy and functional. A good introduction can be found at NSHipster.

Objection

Objection is a dependency injection framework created by our own Justin DeWind. It enables us to write classes that don’t need to know how to instantiate each other. Paraphrasing from a 2009 I/O presentation, a dependency injection framework is an everything-factory that you don’t have to write or maintain.

OCMockito

We create mock objects, stub properties on them, and verify expected behavior with OCMockito. I like its permissive behavior, wherein it records function calls as they occur for later verification at the end of the test. This frees us from over-specifying the behavior under test, resulting in unit tests that are less brittle.

Alternative: OCMock

Specta/Expecta

Specta is a test runner compatible with XCTest; Expecta is a matcher framework from the same authors. Read more about their merits here.

Alternative runners: Kiwi, Cedar, XCTest, Quick, Sleipnir (Swift)

Alternative matcher: OCHamcrest

KIF

KIF is an integration testing framework that allows us to programmatically interact with an app’s UI. It hooks into iOS’ accessibility features, allowing you to e.g. waitForViewWithAccessibilityLabel:"Welcome!" and then tapViewWithAccessibilityLabel:"Next".

KIF is an integration testing framework that allows us to programmatically interact with an app’s UI. It hooks into iOS’ accessibility features, allowing you to e.g. waitForViewWithAccessibilityLabel:@"Welcome!" and then tapViewWithAccessibilityLabel:@"Next".

Alternatives: Instruments, Zucchini

Underscore.m

Underscore.m is “a functional toolbelt for Objective-C” inspired by underscore.js If you find yourself pining for features from functional languages, this is for you.

Mantle

Mantle provides a number of features that make working with data-holder objects more convenient. Notably, it provides default implementations of -isEqual: and the methods for the [NSCopying][NSCopying] and [NSCoding][NSCoding] protocols.

Masonry

We build user interfaces with Masonry, which wraps Auto Layout with a sweeter DSL.

CocoaLumberjack

CocoaLumberjack is a logging framework (see what they did there?). It provides a number of features over the ubiquitous NSLog, notably including the ability to capture the output.

HockeyApp

Hockeyapp provides an easy way to get beta builds out to our customer every week. Hopefully we won’t need it, but the crash reporting looks fantastic.

Conclusion

Open source allows a small team to build great things by standing on the shoulders of giants.

At a consultancy like AO, every new project presents an opportunity to use new tools. What did you choose for your current project?