[CocoaHeads Tricity] Do not reinvent the wheel

25
Do not reinvent the wheel Make use of Cocoa libraries and ready components Mateusz Klimczak

Transcript of [CocoaHeads Tricity] Do not reinvent the wheel

Do not reinvent the wheelMake use of Cocoa libraries and ready components

Mateusz Klimczak

Agenda! Overview of the most popular Cocoa

libraries and ready components ! When to use ready components? ! CocoaPods – an easy way to organise

your components ! Let’s create our own Pod ! Use Gemfile to control the CocoaPods

version ! Discussion

! Probably the most popular iOS library ! Main features:

! Encapsulates the common patterns of communicating with a web application over HTPP: GET, POST, PUT, DELETE, etc.

! Easy request serialisation ! Since 2.0 version support for caching

downloaded images (both in-memory and disk caching)

! Network reachability manager

ReactiveCocoa! Objective-C framework inspired by

Functional Reactive Programming ! Provides APIs for composing and

transforming streams of values ! Instead of using mutable variables RAC

provides signals that capture present and future values

! Widely discussed on last meeting

RAC – usage example

! Amazing tool for crash reporting with support for both iOS and Android

! Provides detailed statistics about crashes ! Recently integrated into Twitter’s Fabric.IO

– mobile platform for mobile analytics, app distribution and reporting

! Allows integration with Trello&BitBucket ! Live example!

CocoaLumberjack! Logging framework for Mac and iOS ! Faster than NSLog ! Main features:

! Send logs over the network ! Use multiple loggers to log simultaneously to

many places (file, console, database) ! Define different log levels per logger

(e.g. log verbose to console, but briefly to log server)

MagicalRecord! Inspired by RoR Active Record Fetching ! Active Record is an approach to accessing

data in database ! Database table is wrapped into a class ! Object instance is tied to a single row in the

database table ! The wrapper class implements properties for

each column in the table ! Allows clear, simple, one-line fetches from

CoreData

FXKeychain! Lightweight wrapper around the Apple

keychain API ! Exposes the commonly used functionality

while hiding complexity of underlying APIs

RHAddressBook! Library for interfacing with the iOS

AddressBook ! All contact attributes on various objects

(Person, Group) are exposed as properties – no more dealing with CF methods

TPKeyboardAvoiding! Universal solution for moving text fields out

of the keyboard in iOS ! Uses UIScrollView/UITableView subclasses

that handles everything for you

PaymentKit! Library providing utility methods for dealing

with credit card payments: ! Credit card number validation&formatting ! Expiration validation ! Credit card type checking ! Credit card providers icons fetching ! Ready to use UI components for to input

card data

card.io

! Provides ready to use credit card scanning

XMLDictionary! Library for parsing and generating XMLs ! Allows parsing XML received from server to

NSDictionary and vice versa

TSMessages! Provides an easy to use class to show little

notification views on the top of the screen

MSDynamicsDrawerViewController! Container view controller

that manages the presentation of a single view controller overlaid over drawer view controllers

! Supports swipe to open and close the drawer

MBProgressHUD! Customisable, easy to use progress HUD

with an indicator while work is being done in background thread

JSQMessagesViewController! Messages UI library for iOS ! Allows displaying media, map location and more

And many, many more…! Kiwi ! Specta ! Masonry ! PureLayout ! GPUImage ! JSONKit ! Facebook/Twitter/Google ! …

When to use ready components? ! We want to save some time (it’s not

always worth it – to be continued) ! Library/component is still developed and

preferably have more than 1 contributor ! We don’t need a full control of the code ! We don’t need to provide a high-level

security ! If it is a UI component, we don’t have to

create highly customised interface

! Dependency manager for Swift and Objective-C project

! According to the http://rubygems.org currently there are over 1.1 million downloads of CocoaPods (it doesn’t mean that there are that many users)

! http://cocoapods.org sites are generating 180k visits per month

! You can try the demo project of the Pod without integrating it into your project

! It’s easy to get started ! Installation:

! gem install cocoapods ! Create Podfile

! pod init ! Add pods references to your Podfile ! Run command:

! pod install ! Use .xcworkspace instead of .xcodeproj

! Life example – let’s create our own Pod!

! Instructions: http://guides.cocoapods.org/making/making-a-cocoapod.html

Gemfile! Use Gemfile to keep the same version of

CocoaPods for everyone in team ! Gemfile should specify the required version

of CocoaPods ! Install pods using:

! bundle exec pod install

Discussion! ! What libraries do you most often use? ! When do you prefer to write your own

code? ! Your experiences!