It's common to explicitly include open source code in iOS (or OS X) development. Cocoapods is a dependency manager that lets you track dependencies on 3rd party code, which in Cocoapods terminology, is known as pods, as well as update an Xcode workspace — which wraps around your Xcode project file – so all you need to do is the following:
-
Install cocoapods if you haven't:
sudo gem install cocoapods
-
Create a Podfile in your Xcode project directory:
pod init
-
Update the Podfile to list which pod(s) and version you would like to use:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' use_frameworks!
pod 'AFNetworking', '~> 2.5' pod 'ORStackView', '~> 2.0' pod 'SwiftyJSON', '~> 2.1'
-
Install the dependencies:
pod install
-
Open the
.workspace
file instead of.xcodeproj
file. -
Import dependencies like this:
import <AFNetworking/AFNetworking.h>
You then iterate through steps 3-6 during development and never use the .xcodeproj
file again.
You can search for available pods at Cocoapods as well as for additional documentation.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.