DEV Community

ryanzzff
ryanzzff

Posted on

Using Cocoapods with Gemfile

If you work in a team, it would be better if all team members have the same development environment. For instance, as an iOS developer, if we are using a different version of Cocoapods to install the 3rd party libraries, the generated Podfile.lock or the .xcworkspace file might be slightly different.

We can use a Gemfile to sync it:

Step 1. Create a file named Gemfile in the same directory of the Podfile and .xcodeproj

source 'https://rubygems.org'
gem 'cocoapods'

you may also specify the version of the cocoapods:

source 'https://rubygems.org'
gem "cocoapods", "1.8.4"

Step 2. Install bundler with gem in user directory

gem install bundler --user-install

Step 3. Install cocoapods with the version specified for the project (into the local relative path vendor/bundle)

bundle install --path vendor/bundle

To verify the version installed:

bundle exec pod --version

Step 4. Instead of using pod install, we now have to use a new command:

bundle exec pod install

Bonus:
We can open the .xcworkspace file automatically with Xcode right after pod install:

bundle exec pod install && xed .

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay