Topic 3 Posts

fastlane

Setting up Fastlane on a remote server

In the previous article I went through the steps on how to setup Fastlane on your Mac, but what if you would want to have a remote machine doing all the heavy lifting, getting loud and hot and keeping your computer cool and quiet while building your project? Well you can do that.

First ssh into your remote machine, then follow my manual on how to setup Fastlane on your computer and go through all the steps but with a remote machine.

What's the point of this article you would ask? It's mostly to reiterate on the issues you might face while running fastlane beta on the remote server. For example there is a high chance that you might encounter Fastlane's errSecInternalComponent error which is actually pretty easily resolvable by going through the archive and export routine and unlocking keychain via ssh. All the details are in this link.

Fastlane errSecInternalComponent error

If you tried running Fastlane on a remote machine, you might have encountered this error. In short: Fastlane has troubles signing in your components and binary before for example uploading them to TestFlight.

To overcome the issue you should do the following:

  1. VNC into the remote machine and do a Build->Archive and export to App Store routine. When you'll see the codesign prompt, let it 'Always Allow', thus making to remember that xcode-tools are whitelisted
  2. After ssh-ing into the remote machine, before starting Fastlane, enter the following into Terminal: security unlock-keychain login.keychain - this will allow using the codesigning private key in Fastlane launched via ssh.
  3. Start your lane of choice by using fastlane <lane> and enjoy Fastlane without the codesigning error.

Setting up Fastlane for mobile automatization on Mac OS

Fastlane is used to automatize different routines in mobile development. In this note (or serious of notes) I'll describe how to use Fastlane to automize your iOS project builds and uploads to TestFlight.

You start by installing latest Xcode tools
xcode-select --install

Next, you install Fastlane via RubyGems
sudo gem install fastlane -NV

or via brew
brew cask install fastlane

Then cd to your project and initialize Fastlane:
fastlane init

Last, edit fastlane/Fastfile to this:

platform :ios do

  before_all do
    ENV["FASTLANE_DONT_STORE_PASSWORD"] = "1"
    ENV["FASTLANE_USER"] = "<Your App Store Connect email"
  end

  desc "Build and upload to TestFlight"
  lane :beta do
        build_app(scheme: "<Your project's scheme>",
                      workspace: "<Your project's>.xcworkspace",
                  include_bitcode: true)
        upload_to_testflight
  end
end

If you want to store your password in the Keychain, just remove ENV["FASTLANE_DONT_STORE_PASSWORD"] = "1"

If you want to store your password in the Fastfile, add ENV["FASTLANE_PASSWORD"] = "<yourPassword>" into the before_all do / end section.

Now run 'fastlane beta' in your Terminal and enjoy an automatic build and upload to TestFlight 🙂

You can use this manual on your own computer. For running it on a remote machine look out for part 2 of this series.