Xcode development using Cocoapods
/ 1 min read
Table of Contents
Problem
Manage 3rd party libraries in Objective-C projects.
Solution
Use Cocoapods for library management in Objective-C projects.
Step 1
Install cocoapods gem and initialize.
$ gem install cocoapods# If you are using rbenv do not forget to rehash$ rbenv rehash$ pod setupStep 2
Create a Podfile and list dependencies.
$ cd ~/foo # your xcode project root folder$ vim Podfileplatform :ios, '5.0' # deployment target SDKpod 'AFNetworking', '~> 1.2.0' # means we need AFNetworking version 1.2.0 or higherStep 3
Now install dependencies.
$ pod installAnalyzing dependenciesDownloading dependenciesInstalling AFNetworking (1.2.1)Generating Pods projectIntegrating client project
[!] From now on use `foo.xcworkspace`.Cocoapods creates an Xcode workspace and Pods static library project, then links it with your project. All your dependencies will be available through that library. As the output suggests, use foo.xcworkspace from now on.
$ open foo.xcworkspaceDiscussion
Cocoapods certainly makes it easier to manage libraries in your project. You can search the library you want to use.
$ pod search TestFlightSDKAs well as Xcode workspaces have some advantages described in Xcode Concepts which we discuss in Core Data: Automate master data preloading.