devxlogo

Ten Fantastic Objective-C Libraries for iPhone Developers

Ten Fantastic Objective-C Libraries for iPhone Developers

After having spent more than a decade working almost exclusively with the web, I decided to branch out and try my hand at something entirely new: iPhone development. The transition was surprisingly difficult, largely because the Objective-C community doesn’t yet enjoy a mature open source software ecosystem available to languages such as Ruby (via Bundler), PHP (via Composer), or Perl (via CPAN). The number of quality third-party libraries does however continue to grow, and thanks to the popular CocoaPods library dependency manager it’s easier than ever to incorporate these libraries into your iOS and OSX applications.

If you’re new to or considering jumping into Objective-C development, then chances are you’re similarly inclined to find quality libraries in order to speed your own development activity. In this article I’ll highlight ten Objective-C libraries I’ve come to find indispensable while working on my first iPhone application. Obviously this merely scratches the surface in terms of what’s available through CocoaPods, so be sure to head over to the CocoaPods website and spend some time searching the repository to learn what else is available.

Google Maps SDK for iOS

The app I’m currently working on is a niche travel guide, and integrates numerous maps for helping the user identify points of interest. Of course, Apple offers native support for integrating Apple Maps, however as I already have years of experience working with the Google Maps API it seemed prudent to at least take a look at the Google Maps SDK for iOS in the hopes of being able to adapt this knowledge and experience to iOS development. I wasn’t disappointed as many of the concepts and syntactical constructs are very similar to those used within the Google Maps JavaScript API.

As far as libraries go, the Google Maps SDK for iOS requires a fair bit of project configuration in order to work properly within the confines of your project. However, these steps are fairly straightforward, and followed closely you’ll be displaying maps within your iOS application in no time flat.

FMDB

Newcomers to iOS development might be surprised to learn that the powerful SQLite relational database is available by default for your application’s data persistence needs. Most developers will opt to use the Core Data framework for such matters, a general purpose data management solution which eases the pain otherwise incurred managing persisted data within your iOS applications, Core Data’s learning curve is admittedly steep. If your data persistence needs are fairly simplistic, then you might consider taking a look at the Objective-C SQLite wrapper FMDB.

Installing and using FMDB is surprisingly easy. For starters, you have the luxury of using an existing SQLite database, making it available to your application simply by copying the database into your application directory (there is no such convenience available when working with CoreData, at least without first making some adjustments to the database structure). Once available, the process required to retrieve or modify data isn’t particularly dissimilar to that used when using similar libraries within web development. For instance, the following is an admittedly simplified by working snippet which opens a SQLite database named locations.sqlite and retrieves a result set containing all locations found in a table named locations:

NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);NSString *documentsDir = [docPaths objectAtIndex:0];NSString *dbPath = [documentsDir   stringByAppendingPathComponent:@"locations.sqlite"];FMDatabase *database = [FMDatabase databaseWithPath:dbPath];[database open];FMResultSet *results = [database executeQuery:@"SELECT id, name FROM locations"];

While the simplicity of FMDB is indeed attractive, particularly when compared to Core Data’s relative complexity, in my admittedly limited experience (and based on the advice of several far more knowledgeable colleagues) it seems apparent that sticking to Apple’s native Core Data offering is ideal in most situations. However FMDB certainly has its place, and warrants a look if you’re planning on persisting application data.

Mogenerator

Presuming you do heed the last section’s closing advice and adopt Core Data, you will undoubtedly want to take a look at Mogenerator, a fantastic library which among other things resolves one wildly annoying inconvenience associated with using Core Data which has to do with how Core Data entities are managed. Thanks to an Xcode tool known as the Core Data Model Editor, you can create and manage your model objects, which are then made available as classes which inherit from the NSManagedObject class. These classes contain a variety of properties and methods, just as you would expect. However, you cannotenhance these classes by for instance adding additional convenience methods, because one or more of these classes will be overwritten should you later decide to modify your schema via the Core Data Model Editor.

Mogenerator solves this problem by generating two files for each entity, one which continues to mirror the changes made through the Core Data Model Editor, and a second which you can use to manage custom changes made to the entity (such as adding methods and other useful accoutrements).

Although I think this feature alone makes Mogenerator worth using, it also happens to offer several other conveniences, including a variety of useful helper methods which further ease some of the pain incurred when using Core Data.

Incidentally, Mogenerator departs from the other libraries discussed in this article in that it is the only one not available via CocoaPods. Instead, you’ll install it via a DMG installer, which you can download from here.

AFNetworking

Although nobody is keeping score, AFNetworking is possibly the most popular Objective-C library on the planet. According to the AFNetworking developers, the library is a key part of some of the world’s most popular iOS apps, among them Vine and Pinterest. So what’s all the hubbub about? AFNetworking is in essence a networking library, providing you with the ability to perform common networking tasks such as retrieving and parsing JSON, downloading images, and communicating with web services.

While AFNetworking provides you with the framework for implementing any conceivable sort of network-related feature, a growing number of AFNetworking extensions likely make your task even easier, offering solutions for interacting with the Amazon S3 API, parsing iCalendars, and measuring connection speed.

RestKit

Logically many of today’s iOS applications will interact with an organization’s RESTful web service. While building such services using web frameworks such as Rails is increasingly simple thanks to ample documentation and robust framework features, building customer Objective-C solutions for consuming these services is another matter entirely. The RestKit library erases much of the complexity associated with building Objective-C clients by providing an object mapping solution which serves as a bridge between Core Data and the RESTful resources which comprise the web service.

If you’d like to learn more about what RestKit has to offer, the RestKit GitHub repository offers a fantastic tutorial complete with a sample project. I highly recommend using this resource as your starting point if you’d like to know more about what’s possible using this powerful framework.

Nui

Without question dealing with iOS layouts and UI stylization is one of the most frustrating aspects of transitioning from web to iOS development. Web developers have an infinite number of tools at their disposal for building and managing web interfaces, whereas the task is often frightfully constraining for iOS developers lacking adequate design skills. Enter Nui, a library which gives you the ability to stylize UI elements using a style sheet. Using Nui you can stylize your iOS app by adapting the very same knowledge you’ve accumulated over the years building web sites, using CSS styles to define font, button, and background styling, among others.

FontAwesome+iOS

You’ll undoubtedly want to incorporate icons of various sorts into your iOS application, using them to spruce up your interface and provide users with visual cues pertaining to widgets associated with tasks such as application navigation, data deletion, audio/video playback, and content synchronization. Perhaps the de facto such icon set is Font Awesome, the iconic font bundled with Bootstrap. iOS developers can easily incorporate the icons available via the Font Awesome font into their apps thanks to the FontAwesome+iOS library.

After configuring FontAwesome+iOS (see the README for instructions), you can easily add any of the hundreds of vector-based icons made available via the Font Awesome set (see the list here). For instance, the following bit of code creates the screen presented in Figure 1.

 [bigButton setTitle:@"Go to My GitHub Page" forState:UIControlStateNormal];[labelHello setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:100]];labelHello.text = [NSString fontAwesomeIconStringForIconIdentifier:@"icon-github"];[labelHello setTextAlignment:NSTextAlignmentCenter]; 

A sample FontAwesome screen
Figure 1. A sample screen created using Font Awesome’s GitHub icon.

Incidentally, FontAwesome+iOS isn’t the only option for adding high quality icons to your iOS application. For instance my current project integrates the amazing GLYPHICONS library, which at a cost of $59 as of the time of this writing is a real bargain considering it places almost 500 icons at your disposal.

String Stylization with TTTAttributedLabel and FormatterKit

Thanks to view helpers, CSS and other formatting solutions it’s fairly trivial to stylize text within a web application, adding padding, indentation, and shadows, not to mention humanizing units (displaying 1,000 KB as 0.97 MB, for instance), and converting numbers (cardinals to ordinals, for instance).

There are two great libraries capable of fulfilling these sorts of needs and more within your iOS applications, including TTTAttributedLabel and FormatterKit. TTTAttributedLabel offers a wide array of features useful for string formatting, including paragraph style indentation, line height adjustments, shadows, and insets, as well as text context type detection capabilities for properly formatting URLs, phone numbers, and dates, among others.

FormatterKit offers a number of formatting conveniences largely related to the humanization of data such as mailing addresses, numbers, and arrays. For instance, you can use FormatterKit to turn an array such as [@”AM”, @”FM”, @”Shortwave”] into the user-friendly string, “AM, FM, and Shortwave”.

ViewDeck

There are several iOS apps I use every single day which include a user interface feature known as a “sliding view” (including AnyList, an indispensable app my wife and I use all the time). An example of AnyList’s sliding view UI is presented in Figure 2.

A sample sliding view UI
Figure 2. An example sliding view UI (from the AnyList application)

Indeed this is such a commonly desired feature that there are numerous open source implementations, however ViewDeck seems to be a particularly popular solution, having garnered quite a GitHub following. Although I haven’t yet had the opportunity to integrate ViewDeck into an application, I’d imagine its popularity largely has to do with its numerous features, including the ability to create left- and right-side side views, set the ledge size, and animate the movement in a variety of ways.

Conclusion

Hopefully this short list of popular libraries will be of some help in ramping up your Objective-C development. Do you use a particular Objective-C library not listed here? Tell us about it in the comments.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist