CocoaPods are a must for any serious iOS project. Why reinvent the wheel when the community has produced robust and feature-rich plugins? However, one can get easily overwhelmed with the amount of choices out there. So in this post, I’d like to highlight the best CocoaPods I’ve used in real-world project that are also Swift-friendly. By that I mean, they are either pure-Swift or at least Objective-C pods that have been updated to be compatible with Swift. Here we go…
- Alamofire – You won’t find a “top CocoaPods list” without this pod on there. It allows you to easily consume web services and do other HTTP network tasks. The API is much sweeter and elegant than Apple’s rigid and verbose `NSURLConnection` (although Alamofire is just a wrapper to it).
- SwiftyJSON – Another heavy-hitter in the Swift CocoaPods world. Parse JSON with ease instead of using Apple’s verbose `NSJSONSerialization` syntax.
- Timepiece – Working with dates in Objective-C is such a boring task. The trend continues in Swift unfortunately. This is where Timepiece comes in. Working with dates feels natural, such as comparing dates using arithmetic symbols, or format with ease instead of using Apple’s verbose `NSDateFormatter` API. Apple just loves verbose syntax don’t they!
- EAIntroView – Ever wanted to create a tutorial for your iOS app? Sure you can create a `UIPageControl` and wire everything up. This pod makes things easier though. Just a few lines of code in your `ViewController` and you’ve got a beautiful tutorial!
- MZTimerLabel – When working with Apple WatchKit, one thing I really liked that was missing in iOS was WKInterfaceTimer, or a countdown label. To get a countdown or timer working in iOS, you could get messy with NSTimer, yes verbose again! That’s where this pod comes in. Just instantiate with any label as a constructor parameter and you’ve instantly got a timer API around it. Beware though, when your app goes in the background, the timer goes stale or acts funny. I don’t fault this as a bug, but just the way the iOS architecture works to manage resources. I’ve posted a workaround in a GitHub issue to resolve this and still let iOS manage its resources properly.
- AlecrimCoreData – You want to talk verbose, try working with the raw CoreData syntax from Apple. Yuck!! AlecrimCoreData wraps the CoreData API and produces an elegant framework on top. Sorting, filtering, querying – no problem! Since its purely written in Swift, it follows the Swift closure philosophy and makes working with CoreData actually fun and fast! I’ve looked into other wrappers such as MagicalRecord and QueryKit, but they didn’t seem so elegant or fluid. Although those other projects helped inspire AlecrimCoreData, what really sets it apart are its extended `FetchedResultsController` and a class object generator. AlecrimCoreData is the underdog here and I’m hoping this one takes the crown!
- DLImageLoader – There are a ton of async-loading, caching image handlers. Getting one is a must since scrolling your UICollectionView or UITableView will lag like no tomorrow. It’s really something that should be built right into the UIImageView class. So there are so many to choose from, such as SDWebImage and Haneke, but I chose this one because it seemed light-weight and works great!
- SwiftSpinner – Many times, the native UIActivityIndicatorView seems so mediocre. SwiftSpinner generates a modern-looking spinner that keeps the user hypnotized until your app loads its data.
- JSBadgeView – Adding badges on tab bar buttons is a breeze and comes out-of-the-box, but that’s where it stops. Adding badges to buttons, navigation items, segmented controls, and other elements doesn’t come with UIKit. That’s where this pod comes in. Add badges to ANY control that descends from UIView, which is just about everything, but a workaround is available even for non-UIView controls.
- DZNEmptyDataSet – Why there isn’t a property on UITableView or UICollectionView to display an empty message is absurd. This pod does so when you have an empty data set, but it takes it one step further by allowing you to compose an entire view for the empty display.
I hope you enjoy! Do you have any Swift-friendly favorites?
HAPPY CODING!!
***BONUS***
- FileKit – A Swift 2 framework that allows for simple and expressive file management.
- SwiftGen – A collection of Swift tools to generate Swift code (enums for your assets, storyboards, Localizable.strings, …).
- PermissionScope – Intelligent iOS permissions UI and unified API.
- SwiftyUserDefaults – Modern Swift API for NSUserDefaults.
- SwiftyTimer – Swifty API for NSTimer.
- JASON – Fast JSON parsing for Swift.
- Eureka – Elegant iOS form builder in Swift 2.
- RateLimit – Simple utility for only executing code every so often.
- Kingfisher – A lightweight and pure Swift implemented library for downloading and caching image from the web.
- Async – Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch.
PS — Use Carthage! The concept is forward-compatible with Swift Package Manager and doesn’t mangle up your Xcode project files like CocoaPods 😉
Thanks for making this list! I’m just getting started with iOS and swift, and hate how verbose native Swift stuff is. I’ll be using most if not all of these in my first app!