Home fastlane
Post
Cancel

fastlane

Tutorial

Adding fastlane to Your Project

1
2
cd $(PROJECTDIR)
fastlane init

Appfile

Stores the app identifier, your Apple ID and any other identifying information that fastlane needs to set up your app.

Fastfile

Manages the lanes you’ll create to invoke fastlane actions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
default_platform(:ios)

platform :ios do
# 1
  desc "Create app on Apple Developer and App Store Connect sites"
# 2
  lane :create_app do
# 3
    produce
  end
  
  desc "Take screenshots"
  lane :screenshot do
    snapshot
  end
  
  desc "Create ipa"
  lane :build do
    # 1
    enable_automatic_code_signing
    # 2
    increment_build_number
    # 3
    gym
  end

end
  1. Provides a description for the lane. (A lane is a workflow of sequential tasks).
  2. Names this lane create_app.
  3. Uses produce to add the app to both the Developer Portal and App Store Connect.
1
2
3
4
# Note: If your App Store Connect and Apple Developer Portal usernames are different, replace the apple_id line with:

apple_dev_portal_id("[[APPLE_DEVELOPER_ACCOUNT_USERNAME]]")
itunes_connect_id("[[APP_STORE_CONNECT_ACCOUNT_USERNAME]]")

Generating the Deliverfile

1
bundle exec fastlane deliver
  • The metadata directory, which will hold the majority of the app’s metadata.
  • Deliverfile, which will hold a few remaining pieces of metadata.
  • The screenshots directory, which will contain the app screenshots.

In the metadata directory, you’ll notice a bunch of text files named after common App Store items like the description, keywords, categories, etc. fastlane will use these files to submit your app’s metadata information to App Store Connect.

en-US/description.txt

1
mZone is a simple poker calculator for No Limit Texas Hold 'Em tournaments that displays a recommended course of action based on your chip count and the current big blind level.

keywords.txt

1
Poker, Cards, Gambling
  • Add Copyright (c) 2019 Razeware LLC to copyright.txt.
  • Add Games to primary_category.txt.
  • Add Card to primary_first_sub_category.txt.
  • Add Casino to primary_second_sub_category.txt.

Then, in the same folder, use your favorite text/code editor to create a JSON file named app_store_rating_config.json containing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
  "CARTOON_FANTASY_VIOLENCE": 0,
  "REALISTIC_VIOLENCE": 0,
  "PROLONGED_GRAPHIC_SADISTIC_REALISTIC_VIOLENCE": 0,
  "PROFANITY_CRUDE_HUMOR": 0,
  "MATURE_SUGGESTIVE": 0,
  "HORROR": 0,
  "MEDICAL_TREATMENT_INFO": 0,
  "ALCOHOL_TOBACCO_DRUGS": 0,
  "GAMBLING": 2,
  "SEXUAL_CONTENT_NUDITY": 0,
  "GRAPHIC_SEXUAL_CONTENT_NUDITY": 0,
  "UNRESTRICTED_WEB_ACCESS": 0,
  "GAMBLING_CONTESTS": 0
}

And, lastly, in the review_information folder, add your email address to email_address.txt, your first name to first_name.txt, your last name to last_name.txt and your phone number to phone_number.txt. Preface the phone number with ‘+’ followed by the country code, for example; +44 844 209 0611.

Automating Screenshots

1
fastlane snapshot init

A Snapfile file will now appear in your fastlane folder. Open it and replace the contents of the file with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 1 - A list of devices you want to take the screenshots from
devices([
  "iPhone 8 Plus",
  "iPhone SE"
])

# 2 - A list of supported languages

languages([
  'en-US',
  'fr-FR'
])

# 3 - The name of the scheme which contains the UI Tests

scheme("mZone Poker UITests")

# 4 - Where should the resulting screenshots be stored?

output_directory "./fastlane/screenshots"

# 5 - Clears previous screenshots

clear_previous_screenshots(true)

Fastfile update:

1
2
3
4
  desc "Take screenshots"
  lane :screenshot do
    snapshot
  end
1
bundle exec fastlane screenshot

Creating the IPA File

1
fastlane gym init

Open Gymfile and replace its contents with:

1
2
3
4
5
6
7
8
9
10
# 1
scheme("mZone Poker")
# 2
output_directory("./fastlane/builds")
# 3
include_bitcode(false)
# 4
include_symbols(false)
#5
export_xcargs("-allowProvisioningUpdates")
  1. Specifies mZone Poker’s scheme.
  2. Specifies where fastlane should store the .ipa app binary file.
  3. Excludes bitcode from the build. Bitcode allows Apple to optimize your app, but exclude it for now to speed up the build.
  4. Excludes symbols from the build. Including symbols allows Apple to access the app’s debug information, but exclude it for now to speed up the build.
  5. Allows Xcode to use automatic provisioning.

Fastfile update:

1
2
3
4
5
6
7
8
9
  desc "Create ipa"
  lane :build do
    # 1
    enable_automatic_code_signing
    # 2
    increment_build_number
    # 3
    gym
  end
  1. Enables automatic provisioning in Xcode.
  2. Increases the build number by 1 (so each build number is unique per App Store Connect’s upload requirement).
  3. Creates a signed .ipa file.

Uploading to App Store Connect

Deliverfile update:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 1
price_tier(0)
# 2
submission_information({
    export_compliance_encryption_updated: false,
    export_compliance_uses_encryption: false,
    content_rights_contains_third_party_content: false,
    add_id_info_uses_idfa: false
})
# 3
app_rating_config_path("./fastlane/metadata/app_store_rating_config.json")
# 4
ipa("./fastlane/builds/mZone Poker.ipa”)
# 5
submit_for_review(true)
# 6
automatic_release(false)
  1. Set price tier to 0, indicating it’s a free app.
  2. Answer the questions Apple would present to you upon manually submitting for review.
  3. Provide the app rating configuration location.
  4. Provide the .ipa file location.
  5. Set submit_for_review to true to automatically submit the app for review.
  6. Set automatic_release to false so you’ll have to release the app manually after it’s accepted by app review.

Putting It All Together

Fastfile update:

1
2
3
4
5
6
7
  desc Create app, take screenshots, build and upload to App Store"
  lane :do_everything do
    create_app
    screenshot
    build
    upload
  end
This post is licensed under CC BY 4.0 by the author.