Getting Started with CocoaPods:
This is a guide to help developers get up to speed with CocoaPods library. It is geared primarily towards anyone who is new to Mac or iOS development, or has not worked extensively with 3rd-party libraries before.Step 1: Download CocoaPods
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects.CocoaPods is distributed as a ruby gem, and is installed by running the following commands in Terminal.app:
$ sudo gem install cocoapods
$ pod setup
Depending on your Ruby installation, you may not have to run as
sudo
to install the cocoapods gem.
Step 2: Create a Podfile
Project dependencies to be managed by CocoaPods are specified in a file calledPodfile
. Create this file in the same directory as your Xcode project (.xcodeproj
) file:$ touch Podfile
$ open -e Podfile
TextEdit should open up showing an empty file. You just created the pod file and opened it! Ready to add some content to the empty pod file?
Copy and paste the following lines into the TextEdit window:
i.e:
platform :ios, '7.0'
pod 'AFNetworking', '~> 2.0'
Step 3: Setup environment
Run this command in your project for setup the CocoaPods environment:$ pod setup
Step 4: Install Dependencies
Now you can install the dependencies in your project:$ pod install
From now on, be sure to always open the generated Xcode workspace (.xcworkspace
) instead of the project file when building your project:$ open App.xcworkspace
Step 5: Dive In!
At this point, everything's in place for you to start using AFNetworking. Just#import
the headers for the classes you need and get to it!
No comments:
Post a Comment