Some users may hit the following error while running bundle install after switching from an Xcode 10.x image to the Xcode 11 image on CircleCI.
The main error message to note is the following:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
Why does this happen?
Recent versions of Xcode have removed the previously bundled macOS SDK headers package which installed the various Ruby 2.3 (system Ruby) headers required to build Ruby Gems. Without these headers, some Gems will fail during the bundle install phase with the following error message:
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
Steps to Resolve
This can be resolved by switching to one of the Ruby versions, available via chruby, that we ship with the Xcode 11 image.
In the latest Xcode 11 GM Seed 2 image, we include Ruby 2.5.5 and 2.6.3 (software manifest).
Follow the steps in our Using Custom Ruby Versions guide to switch to either Ruby 2.5.5 or Ruby 2.6.3. Once you have updated your config.yml, push a fresh commit to trigger a fresh build.