Skip to content

Instantly share code, notes, and snippets.

@ast3150
Last active October 10, 2022 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ast3150/786c676e6c7639f9a5137cbd00cf33c6 to your computer and use it in GitHub Desktop.
Save ast3150/786c676e6c7639f9a5137cbd00cf33c6 to your computer and use it in GitHub Desktop.
Example Fastlane Setup
# General Constants
APP_NAME = "myProject – PROD" # So you can identify your app in Slack, logs, etc.
# Team
USERNAME = "appstore@yourcompany.com" # The Username that you use to log in to AppStore Connect, or developer.apple.com
TEAM_ID = "ABCDEFGH"
# Code Signing
BUNDLE_ID = "com.yourproject.ent.prod" # Your App Bundle Identifier
# Gym
GYM_BUILD_SCHEME = "myproject-prod" # The Build scheme as it is called in Xcode
GYM_EXPORT_METHOD = "enterprise" # development, ad-hoc, enterprise, app-store
# Match
MATCH_TYPE = "enterprise" # development, adhoc, enterprise, appstore
MATCH_GIT_URL = "ssh://git@gitlab.yourinstance.net/ios-team/certificates" # Path to your match certificates repo
MATCH_GIT_BRANCH = "master" # Customize if needed, e.g. for different teams
# Updraft. You can generate this in your Updraft project settings
UPDRAFT_URL = "https://getupdraft.com/api/app_upload/some-updraft-url"
# Slack
SLACK_URL = "https://hooks.slack.com/services/some-slack-webhook" # A custom Slack Incoming Webhook, you can generate this through Slack.
# Firebase
GSP_APP_ID = "1:some:id:ios"
import_from_git(url: "https://github.com/appswithlove/fastlane_tools.git", branch: "master")
fastlane_require 'xcov'
platform :ios do
##### QUALITY #####
desc "Lint code"
lane :lint do
cocoapods(try_repo_update_on_error: true)
swiftlint(
reporter: "codeclimate",
output_file: "./fastlane/swiftlint.json",
path: "./"
)
end
desc "Run all tests"
lane :test do
cocoapods(try_repo_update_on_error: true)
scan
xcov(
scheme: ENV["GYM_BUILD_SCHEME"],
output_directory: "./fastlane/xcov_output",
html_report: true,
markdown_report: true,
json_report: true
)
end
##### BUILD #####
desc "Builds"
lane :build do
match(readonly: true)
clear_derived_data
cocoapods(try_repo_update_on_error: true)
increment_build
gym(output_name: "#{ENV['GYM_BUILD_SCHEME']}.ipa")
end
##### DEPLOY #####
desc "Builds the app and uploads to Updraft"
lane :deploy_updraft do
build
updraft
post_build_notification
upload_symbols_to_crashlytics(verbose: true, app_id: ENV["GSP_APP_ID"])
end
##### HELPERS #####
desc "Get certificates, pass 'dist:true' for distribution, create:true' for creation, 'force:true' to force"
lane :certificates do |options|
match(
type: options[:dist] ? ENV["MATCH_TYPE"] : "development",
readonly: options[:create] ? false : true,
force: options[:force] ? true : false,
force_for_new_devices: options[:create] ? true : false
)
end
desc "Increment build number to current date and time in UTC, eg. 20190913.1427"
lane :increment_build do
increment_build_number build_number: Time.new.utc.strftime("%Y%m%d.%H%M")
end
desc "Download dSYM files from iTC and upload to Crashlytics. (Apple generates new dSYM when a build is uploaded with bitcode enabled)."
lane :refresh_dsyms do
download_dsyms(team_id: ENV["TEAM_ID"]) # Download dSYM files from iTC
upload_symbols_to_crashlytics(app_id: ENV["GSP_APP_ID"], binary_path: "./fastlane/upload-symbols") # Upload them to Crashlytics
clean_build_artifacts # Delete the local dSYM files
end
desc "Register new device"
lane :register_new_device do |options|
device_name = prompt(text: "Enter the device name: ")
device_udid = prompt(text: "Enter the device UDID: ")
device_hash = {}
device_hash[device_name] = device_udid
register_devices(devices: device_hash)
certificates(
create:true
)
end
end
scheme ENV["GYM_BUILD_SCHEME"]
export_method ENV["GYM_EXPORT_METHOD"]
# Repeat for all values Fastlane reads from other configuration files (Matchfile etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment