CocoaPods is the dependency manager for Objective-C projects. It has thousands of libraries and can help you scale your projects elegantly. According to their web site, anyway. Sounds good to us.
For this tutorial you’ll need the HelloEarth project you created in the last one. Don’t run through the binary and source distribution tutorials. Cocoapods is an alternative to those.
All credit goes to Juan Collas who put together the latest pod (and the old one). We contributed… absolutely nothing. Now that’s what we call open source!
The pod is named WhirlyGlobe, but Maply is in there too. If you go looking for it on cocoapods.org you’ll see this.
Pods are pretty easy to use, which is kind of the point. If you haven’t installed the pod gem, go follow their instructions. You’ll need that software to do the rest of this.
Every project you use Cocoapods in is going to need a Podfile. Yours should look like this.
Make sure you’ve closed the HelloEarth project in Xcode. The install process is going to mess with it.
The next step is to set up the dependencies with the podspec. You do that in the Terminal like so. Navigate to the directory containing your HelloEarth.xcodeproj.
If all goes well it should say something like this.
We love our fellow open source projects. That’s why we include so many of them!
Up next, let’s compile the thing.
You’ll need to load the HelloEarth workspace rather than the project. Cocoapods sets up its dependencies in there. If it fails to compile, odds are you opened the project. We do it all the time.
Just build it. It should scamper off and do the Cocoapods portion first, consisting of all those dependent projects. Then it’ll get to your code.
If it builds, you’re golden. All the source code you need is in there, including all the projects WhirlyGlobe-Maply uses. You can even check all this junk in. There’s a whole body of thought on that, which we won’t get into here.
Go forth and do the rest of the tutorials!