tl;dr - if you have an Xcode project which uses CocoaPods, then you could do well to add a Gemfile to it. This will allow you to specify the version of CocoaPods for the project across collaborators and save you a whole lot of headaches.
I’ve worked on a whole. lot. of. codebases. Some of them big and gnarly and old, others small and new and neat. One thing which brings them together is the universal love of Cocoapods.
One thing that I haven’t noticed is the usage of Gemfiles. Given that CocoaPods is written in Ruby, and given that
A Gemfile describes the gem dependencies required to execute associated Ruby code. [Bundler man]
this is probably a good thing to do. Having a Gemfile allows us to specify a version of CocoaPods to use for our project (so we don’t have some people working on our project using CocoaPods 0.34 and others using 0.37.2 and others using even another version). So let’s do it. Fire up your favourite text editor and create a text file named
Gemfile (no extension) in your project directory and add to it the following:
Make sure you have Bundler installed - if you don’t, run the following from your command line:
gem install bundler
And to now install your CocoaPods using specifically the CocoaPods version specified in the Gemfile run:
bundle exec pod install
Woohoo! CocoaPods installed, and no ambiguity as to what version of CocoaPods you should use. This makes working on a codebase across a large team a whole lot easier when you’re pulling in your dependencies. You should even add the above line to your build server so that it too uses the same version of CocoaPods to build your app.
Best of luck!