Objective-C: Getting Started
I've been working on a project to build an Objective-C framework for about four months now. This post is intended to give you an overview of the landscape of Objective-C development – what tools, frameworks and resources you can expect to use as you work. Hopefully this will be useful to developers moving into mobile! Please note that my experience with Objective-C has been building hybrid mobile apps for a corporate client only so I expect my list will reflect by that (i.e. I know next to nothing about storyboarding and the CI tool I use shall not be named for its terribleness).
What kind of a machine do you need to be an effective dev workstation? Probably a Mac. Technically you can develop on a Windows machine but save yourself a migraine or two and use a Mac if at all possible.
All praise be to Apple, our benevolent overlords. Be prepared to spend hours trying to implement something only to find you literally can’t because they say no. Accept that Apple has very strong opinions and try to roll with it.
Keep in mind that if Apple didn’t develop it they are going to strongly discourage you from using it, even if it’s a fantastic tool. For example, Apple will tell you not to use CocoaPods, a very popular dependency manager for iOS development. This is just bad advice. Do not take the Apple documentation of what you can and can’t do as absolute truth.
You have a choice of sticking to Apple’s official choices and receiving a lot of support from them or trying to break away from their recommended stack as much as possible. This is a tradeoff you should make very carefully; when you choose a tool that Apple doesn’t recommend pay close attention to how much community support it has. Also remember that non-Apple-sanctioned technologies that make it into your app can get your app rejected from the App Store (often Stack Overflow will be able to tell you if this will happen with a particularly library/framework).
Many blogs now understandably focus their writing on Swift rather than Objective-C; expect to search through blog’s archives rather than their latest stuff.
Ray Wenderlich has a ton of iOS tutorials, articles, library recommendations, etc. You are guaranteed to run across his articles at some point in troubleshooting your iOS code.
NSHipster is easy to read, focusing on all types of iOS development and Apple news.
iOSDeveloperTips is another blog you’ll run into a lot if you google your errors.
iOS BDD Beatdown - a very thorough comparison of a bunch of iOS testing frameworks.
Apple Developer Docs is your source of truth... mostly.
StackOverflow is your friend; often the official Apple docs will say you can’t do something – go to SO to check that this is actually true.
XCTest is XCode’s built-in testing framework. Use it mostly for unit tests; it does its job well and as of 2013 has command line support and test running from within XCode. Not a bad default. Side note: OCUnit/SenTestingKit were merged into XCode and eventually re-written as XCTest. You’ll run into references to these all the time but they are essentially obsolete unless your codebase is ancient.
GHUnit is another unit testing framework – doesn’t seem terribly well supported or commonly used (I’ve never used it personally).
OCHamcrest is a library of matchers for use with testing frameworks. You can also write your own matchers. Neat!
Kiwi is a useful and popular BDD framework.
Cedar is another popular framework by Pivotal Labs. Rated as better than Kiwi by iOS BDD Beatdown (link above in the articles section) for its ability to run focused tests and its good documentation.
Specta is another standard BDD framework for iOS. It claims to be more lightweight than Kiwi or Cedar (I have no idea how true that is). You’ll definitely want to use the matcher framework Expecta with this one. Seems to be losing the popularity contest to Kiwi and Cedar.
OCMock is basically the mocking framework for Objective-C. It has support for a bunch of stuff like class mocks, partial mocks, and observer mocks. It boasts some pretty decent documentation plus a strong community for when you need help. Becomes ultra-powerful in combination with OCHamcrest.
OCMockito is a less popular but definitely viable (and well-supported) alternative to OCMock. Especially if you’re used to using Mockito for Java development, this might be a nice place to start.
Calabash is a really nice acceptance testing framework. It supports cucumber for easy-to-learn-ness.
KIF stands for “Keep it functional” and aims to be a lightweight and easy to use functional testing framework. Some caveats: including KIF in your production code can get your app rejected from the app store and version 2.0 is not backwards-compatible with 1.0.
Frank is a Cucumber-based acceptance testing framework similar to Calabash. Claims to be “Selenium for native iOS app”. Bonus: created by an awesome ThoughtWorker, Pete Hodgson!
CocoaPods is a fantastic choice for iOS dependency management. Easy to install, easy to use, widely used and supported, this is an excellent tool overall. Note that it’s easier to start a project with CocoaPods than it is to migrate (since it changes the environment you work in considerably) so you might want to include it up front.
Carthage is a lightweight, unintrusive dependency management tool. Definitely consider it if you’re introducing dependency management into an existing project or you just don’t want to deal with the craziness of CocoaPods like a whole new workspace file.
Caveat: I have used none of these logging frameworks so essentially this is just a summary of what I think of their Github docs ¯\_(ツ)_/¯ Can someone give me a good use case for when you should start prioritizing a logging framework?
CocoaLumberjack seems well-supported and easy to use, especially as it preserves the format of the default NSLog. Also claims to be an order of magnitude faster than NSLog which, if true, is impressive.
LibComponentLogging-Core is a small logging library that adds conditional logging and log levels. The syntax is essentially just a C macro.
NSLogger looks a little crazy on first glance! Its authors describe it as a “high performance logging utility”. It has a desktop logging console which is useful I guess? It strikes me as the fancy sports car of logging frameworks – cool but possibly a lot more than you need.
For the most part you are locked into Xcode and its command line utilities, although you could build a wrapper around these if you really felt like it. Be prepared to struggle a lot at first with finding the appropriate flags, deployment targets, linking settings and certificates.
You can use your CI tools of choice for your Objective-C apps but keep in mind that some will be easier than others. In my day-to-day project we use a Gradle plugin for our pipeline to run our Xcode command line build, test and package commands. Apple has its own CI tool called Xcode Server but pick a tool that gives you what you need, not just one that fits in Apple’s official stack. Particularly if you’re developing other types of products (web-apps for example) alongside your Objective-C app it makes more sense to align your CI tools to match.
Apple’s Device Enrollment Program (DEP) is a pretty handy way to configure your iOS devices straight out of the box. You can turn on or off most settings through this program and do neat things like drop a device directly into single-app mode. Use this in conjunction with a mobile device management program.
There are so many iOS MDM vendors I don’t know how you go about picking a single one. I am most familiar with AirWatch which is okay. It gets the job done despite a sometimes confusing UI and hack-y workarounds to push settings to devices. It does, however, work pretty well for large-scale deployments.
The problem with any non-XCode IDE is that your application’s project file, where the build settings are stored, is incredibly difficult to understand, parse and edit without breaking anything. XCode has a very nice wrapper for this project file and you will need to use it to edit the build settings unless you are very, very sure you know what you’re doing.
XCode. You will have to use XCode at some point even if you do most of your building and testing in the command line. Get familiar with it.
AppCode basically looks like JetBrains took IntelliJ and did a find and replace to add iOS development to it. It could be a useful alternative to XCode but straight out the box it is unintuitive and clunky. Also you’ll still have to have XCode for some stuff anyway.
Use your own text editor! ...but you’ll have to use XCode at some point.
Obviously this is not a comprehensive list of all the Objective-C development tools you could ever need. What other tools or categories of tools do you think are essential to beginning Objective-C development?