Now that we've migrated our tests with fastlane, we can automate the deployment of our app.
Before we can get into the code for Fastfile, you need to configure your project’s provisioning profiles. If you wish to share provisioning profiles with your CI with the minimum configuration, it's best to use match, a tool part of fastlane that securely stores your provisioning profiles and signing certificates. We will not do a complete tutorial on match as the online documentation is awesome and worth digging into. fastlane on its own is moving fast. You can find the recommendations for configuring your Xcode project on the fastlane docs repository: https://docs.fastlane.tools/codesigning/xcode-project/.
Deploying a beta version of your app requires as little code as running the tests:
# If you deploy with travis
# keep this line to unlock the keychain for match
setup_travis
lane :beta do
build_app(scheme: "MyNewProject",
workspace: "MyNewWorkspace.xcworkspace")
# upload to crashlytics
crashlytics(api_token: ENV['FABRIC_API_TOKEN’],
build_secret: ENV[‘FABRIC_API_SECRET’]) if ENV['FABRIC_API_TOKEN'] && ENV['FABRIC_API_SECRET']
# Upload to apple testflight
upload_to_testflight
# Upload to hockey app
hockey(api_token: ENV[‘HOCKEY_API_TOKEN’]) if ENV[‘HOCKEY_API_TOKEN’
end
By default, this beta lane will deploy to testflight with the default configuration. If you happened to set FABRIC_API_TOKEN and FABRIC_API_SECRET, the build would also be uploaded to crashlytics, and setting HOCKEY_API_TOKEN would enable uploading to the hockey app.