Choosing the right version of Cocoapods in your project

With Cocoapods 1.0.0 being close to its release date, we want to remind you that there are breaking changes being introduced in this major new version. You can read about this in more detail in this blog post.

By default, we will run the pod install command to install all the pods specified in your project’s Podfile. This command will use the version of Cocoapods that is pre-installed in the OS X build image, right now it is 0.39.0. If you generate your Podfile with Cocoapods 1.0.0, this might result in a build failure.

To ensure that the version of Cocoapods used in your OS X project is correct at all times, independently of the version pre-installed in our build image, we suggest that you commit a Gemfile to your repo.

In the Gemfile you will be able to specify the version of Cocoapods that you would like to use. Here is an example Gemfile:

# Gemfile
source 'https://rubygems.org'

gem 'cocoapods', '= 0.39.0'

If we detect a Podfile and a Gemfile at the same time, we will run the following commands:

  • bundle install
  • bundle exec pod install

This execute pod install with the version of Cocoapods specified in your Gemfile.

By adding a Gemfile you will be able to choose your own timing around upgrading to Cocoapods 1.0.0—and will make sure that you control the version of Cocoapods being used in your build at every point.

You can find more information about the software pre-installed in our OS X build image in this doc.

1 Like

Thanks for sharing this @alexey this is great!

Hey Alexey,

I’m looking to implement this for us and I’m running into a bundler error:

An error occurred while installing json (1.8.3), and Bundler cannot continue. Make sure that 'gem install json -v '1.8.3'' succeeds before bundling.

Our gemfile:

source 'https://rubygems.org gem 'cocoapods', '= 1.0.0.rc.1' gem 'fastlane'

Do I need to update Bundler on the node?

Would be great to have the output of the gem install json -v '1.8.3' step for debugging—could you please add that step to your circle.yml separately, in the dependencies: pre section?

Also, before doing that, do you mind rebuilding without cache?

1 Like

Manually installing that version of the json gem did the trick! Thanks Alexey!

1 Like

I put this in a file called Gemfile at the root of my repo, but my CircleCI build is still using cocoa pods v. 1.0.0. What could I be doing wrong? Do I need to uninstall v. 1.0.0?

Okay, I found my problem. My circle.yml file was specifying - sudo gem install cocoa pods. Removing that fixed it!

Actually, I have since figured out that sometimes Cocoapods 1.0.x is used, and sometimes 0.39.0 is used, and nothing I do to the circle.yml file actually has an effect. I can rebuild with out changes, and suddenly it uses the right version! What’s going on???

Hi @alexey thank you for sharing this tip!

However, I was not able to get this working out of the box – Circle CI 2.0 simply didn’t do a thing, even though I committed my Gemfile file.

My initial assumption was that updating CocoaPods to specified version and updating all pods would work automatically:

steps:
    - checkout
// ...
// other build instructions here
// ...

When I saw it did not work, I went ahead trying to force it:

steps:
  - checkout
  - run:
      name: Set Ruby Version
      command: echo "ruby-2.4" > ~/.ruby-version
  - restore_cache:
      key: 1-gems-{{ checksum "Gemfile.lock" }}
  - run: bundle check || bundle install --path vendor/bundle
  - save_cache:
      key: 1-gems-{{ checksum "Gemfile.lock" }}
      paths:
        - vendor/bundle
  - restore_cache:
      key: 1-pods-{{ checksum "Podfile.lock" }}
  - run:
      name: Install CocoaPods
      command: |
        curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
        bundle exec pod install
  - save_cache:
      key: 1-pods-{{ checksum "Podfile.lock" }}
      paths:
        - ./Pods
// ...
// other build instructions here
// ...

And it actually started to work!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.