CocoaPods is a command line tool for managing Objective-C dependencies. If you're having trouble following the ObjCMongoDB Getting Started guide (or will be building a number of projects) CocoaPods should be an easier install process. As an added bonus, there are thousands of other dependencies that can be installed via CocoaPods once you're set up.
With the exception of creating your XCode project, the following steps need to be done from a command-line prompt (i.e. Terminal
or iTerm
).
First, install CocoaPods
$ gem install cocoapods
(You may need to sudo gem install cocoapods
if you are using a default Ruby install)
Setup the CocoaPods master repo, which includes definitions of Objective C dependencies that can be installed:
$ pod setup
Create a new Xcode project (or use an existing one)
Create a new iOS or OS X project in Xcode. If you have an existing project, you can skip to the next step.
Change to the project directory
$ cd ~/src/myproject
Create a new Podfile
You can run pod init
and then edit the default Podfile
created, but for simplicity this will work:
$ echo "pod 'ObjCMongoDB', '~> 0.11.0'" >> Podfile
Run pod install
$ pod install
Analyzing dependencies
Downloading dependencies
Installing ObjCMongoDB (0.11.0)
Installing mongo-c-driver (0.8.1)
Generating Pods project
Integrating client project
[!] From now on use `MyProject.xcworkspace`.
Open the workspace file in XCode
$ open MyProject.xcworkspace
#import "ObjCMongoDB.h"
and get started coding your app
You should now be set to start coding with The Basics of using ObjCMongoDB.