One of the great advantages .NET developers enjoy is managed package management and integration with NuGet. Thanks to Cocoa Pods this same functionality is available in iOS through Xcode. CocoaPods enables most iOS and OSX libraries to be configured as dependencies and downloaded into your Xcode project without unnecessary steps for integration and configuration.
Installing Cocoa Pods
Installing Cocoa Pods is extremely easy and is done through Ruby Gems. Simply type the following at the OSX command line:
sudo gem install cocoa pods
At the completion of this command you will be able to utilize the pod command. Hold off for now.
Using Cocoa Pods
Unlike NuGet Cocoa Pods is not yet integrated into Xcode so most of it must be done external. The first step is to create your project as you would normally. This is to give you the directory to using the pod command in. For the remainder of this example, we will refer to our app as MyApp.
Within the root of the project directory (the same level as the .xcodeproj file) perform the following command:
touch Podfile
This file governs what Cocoa Pods will install, right up to the version of the dependency. Below is a sample file which enables the installation of the JSONModel and APLSlideMenu libraries:
target 'MyApp' do pod 'JSONModel' pod 'APLSlideMenu' end
Not specifying a version will cause the latest version to be downloaded.
To actually install these libraries, run the following command
pod install
Once this command completes your Xcode project will be updated. However, it is important to understand how Cocoa Pods alters the structure of your Xcode project to enable this integration. It will create a separate project for itself and require that this project be referenced by the main project.
As with Eclipse, Xcode can operate on a single projects or a group of projects within a workspace. If you check the project directory following the pod install you will find a .xcworkspace file. This is the file you will open to modify the project moving forward.
Additional information on Cocoa Pods (and the full listing of available pods) can be found here: http://cocoapods.org/.