Fastlane is a very useful automation tool for publishing iOS / Android apps. It make the building and deployment process scriptable, which makes it less error prone, and lets you push updates automatically with no manual involvement.
One of the annoying things with fastlane though, is that it doesn’t work :) At least not if you follow the the setup instructions for iOS. According to the setup guide, you need to install Xcode command line tools:
xcode-select --install
And then install fastlane:
sudo gem install fastlane -NV
And then you get a bunch of cryptic errors like:
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
Check the mkmf.log file for more details.
You may need configuration options.
or:
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
or:
ERROR: Error installing fastlane:
ERROR: Failed to build gem native extension.
or:
Building has failed. See above output for more information on the failure.
To see why this extension failed to compile, please check the mkmf.log...
MacOS Mojave comes pre-installed with ruby version 2.3. Fastlane needs a newer ruby. So we need to upgrade ruby. This easiest way to upgrade is with brew.
Open a terminal window and run this (we’re using the old ruby to install brew that will update ruby — mind blown):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Run the following to install latest ruby version (2.6 at date of writing this):
brew install ruby
In order for this version to persist when you open a new terminal window, run:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
Run the following to check the version:
ruby -v
You should get ruby 2.6.0
or something similar. If it’s still 2.3, close the terminal window and open a new one.
Now we can run the installation:
sudo gem install fastlane -NV
If you get this question, answer y
twice:
bundler's executable "bundle" conflicts with /usr/local/lib/ruby/gems/2.6.0/bin/bundle. Overwrite executable?