Cocoa Pods
The best way to manage dependencies in your iOS and Mac projects is using CocoaPods.
CocoaPods is a Ruby gem and work like Bundler simple and functional
First step do you need install CocoaPods as a rubygem
$ gem install cocoapods
It's simple, do you only need create a file named Podfile in your project root path like
$ vim Podfile
and add platform info and dependencies in your Podfile
platform :iOS
pod 'DCKeyValueObjectMapping'
pod 'AFNetworking'
Save & exit, then run pod install command in terminal
$ pod install
Most important, CocoaPods is generated a new xcworkspace file with you project name like, MyProject.xcworkspace, now do you need to use this file to open your project on Xcode.
Can your run
$ open MyProject.xcworkspace
Enjoy!
Written by Fernando Ribeiro
Related protips
4 Responses
Cocoapods are indeed the best way to use any third party code with Xcode
From the Cocoapods site (and from own experience), try to use versions for the dependencies:
pod 'Objection', '0.9'
'Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number.'
'Besides no version, or a specific one, it is also possible to use operators:'
> 0.1 Any version higher than 0.1
>= 0.1 Version 0.1 and any higher version
< 0.1 Any version lower than 0.1
<= 0.1 Version 0.1 and any lower version
~> 0.1.2 Version 0.1.2 and the versions up to 0.2, not including 0.2
Good Jaiversin, thank you
Other way to prevent a incompatibility version is set a min target version for dependency
platform :ios, '5.0'
in platform declaration the '5.0' tell to cocoapods to set a min target iOS 5 to using dependence
using this way you prevent your dependency to update to a incompatibility target version
"Best" is a subjective term. CocoaPods is "a" way to managed dependencies, but it's not the only way