قالب وردپرس درنا توس
Home / IOS Development / fastlane training: Getting started | raywenderlich.com

fastlane training: Getting started | raywenderlich.com



Update Note : Lyndsey Scott updated this tutorial for Xcode 10.1, Swift 4.2, Ruby 2.5.1 and fastlane 2.112.0. Satraj Bambra wrote the original.

It's the glorious moment: You've been greeting days, weeks, or maybe months to build an app, and it's finally ready to share with the world. All you have to do is send it to the App Store. How hard can it be, right?

Cue mountains of grunt work: capture tons of screenshots, add your app to the Apple Developer and App Store Connect sites, upload binary and metadata and other thoughtless work! Argh!

Isn't there a better way? If you could just run a single command that took all of your screens on all your supported devices, each supported language automatically. If there was only one command to upload these screens, add your app to Apple's developer sites and submit everything. Think about all the time you want to save!

Well, you have happiness. :] Thanks to the Creator Felix Krause and Leaders Josh Holtz is a tool to do all this and more! It is called fastlane ! In this tutorial you will learn how to use fastlane to deploy an app to the App Store. It is safe to be your new best friend. Even Google's buddied up with fastlane by acquiring it in 201

7.

  fastlane tutorial

If pins were screenshots, this dog would be almost as useful as fastlane.

Note : This tutorial assumes that you have a Paid Apple Developer account, as well as basic command line knowledge, Xcode and app submission process. If you do not have an account, this guide will help you.

Getting Started

First download the materials for this tutorial at the top or bottom of this page using Download the materials button, then save them in an appropriate location.

This tutorial is a trial app, mZone Poker is a poker calculator for No Limit Texas Hold 'em em tournaments.

Open the mZone project in Xcode to build, run and check it out.

<img src = "https://koenig-media.raywenderlich.com/uploads/2015/09/mzonestarter-278×500.gif" alt = "mZone starts [19659014] Setting up fixedlane

The fixedlane tool is a collection of Ruby scripts so you must have the correct version of Ruby installed. Chances are that your operating system comes with Ruby 2.0 by default, but you can confirm if this is the case by opening Terminal and enter:

  ruby ​​-v

If it is not installed, the easiest way to do this via Homebrew is a packet processing for macOS.

Install Homebrew by entering this Terminal command:

  / usr / bin / ruby ​​- e  t
"$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then you install Ruby using:

  brew update && brew install ruby

Run bryggelink - overwrite ruby ​​ and / or open a new Terminal session if Homebrew instructs you.

You also need Xcode Command Line Tools (CLT) . To make sure they are installed, enter Terminal:

  xcode-select - install

If Xcode CLT is already installed, you get this error: xcode-select: error: command line tool is already installed, use "Software Update" to install updates . If not, continue the installation when prompted.

Now you're ready to install fastlane! Enter the following command to do so:

  sudo gem installation -n / usr / local / bin fastlane --verbose

If you prefer to use Homebrew, type the following command:

  brew cask install fastlane

: With El Capitan, OS X System Integrity Protection also introduced as Rootless which prevents users from having root access. / usr / local / bin is still writable, so you install fastlane there.

Once you have entered your system password, you will see a number of activities in Terminal indicating that the installation is in progress. This may take a few minutes, so grab some coffee, walk your dog or brush up on your zombie-fighting tactics. :]

When the installation is complete, you are ready to set up the fixedlane in the project.

Fastlane Toolchain

To work with his magic, the fastlane brings the following set of tools under one roof:

  • produce creates new iOS apps in both the App Store Connect and the Apple Developer Portal.
  • cert automatically creates and maintains IOS code signing certificates.
  • sigh creates, renews, downloads and repairs commission profiles.
  • still image automates taking localized screens of your iOS app on all devices.
  • frameit sets screenshots to the correct device frames
  • gym builds and packs your iOS apps.
  • supplies upload screenshots, metadata and your apps to the App Store.
  • pem automatically generates and renews your push message profiles
  • space ship is a Ruby library that accesses the Apple Developer Center and the App Store Connect API.
  • pilot automates TestFlight distributions and manages beta testers.
  • boarding invites beta testers
  • match synchronizes certificates and commission profiles across your entire team, using Git.
  • scan runs tests on your apps.

You are using several of these tools today. Enough with the theory for now - it's time to put this tutorial in gear and go into the fast pace!

Add fixedlane to the project

Open Terminal and cd in your mZone startup project. For example, if you added the mZone_Sample_Project folder to your desktop, enter:

  cd ~ / Desktop / mZone_Sample_Project / mZone

To put the mZone start project as a work directory.

Next, enter:

  fixedlane init

To initialize the fastlane.

Notes : If you get a "permission denied" error, prefix this command with sudo .

If sometimes, the fix tells you to update to a newer version, but to run sudo gem update fastlane the output that it is "Nothing to update," perhaps the Ruby leader you are using is not "t updated. Run pearl sources - add https://rubygems.org/ to install Ruby Gems since it is likely to produce the latest information.

After some output, fastlane will ask: "What do you want to use fastlane for?"

  output fast lane init

lane init output

Although the fixedlane "recommends [s] automates a task first," you implement several automated actions during this single tutorial, then enter 4 to start manual setup. Read the output and press Enter when prompted.

Back in the folder mZone you will find a few new things: Gemfile which includes fixed line as a project addiction and a fixedlane folder containing:

  • Appfile : stores the app identifier, your Apple ID, and other identifying information that fastlane needs to configure your app.
  • Fastfile : controls the paths you want to create to invoke fixed actions.

 generated files

Open Fastfile in a text editor of your choice, disable smart quotes if the text editor supports them, and then replaces the contents of the file with:

  default_platform ( : ios)

platform: ios does
# 1
desc "Create app at Apple Developer and App Store Connect sites"
# 2
path: create_app does
# 3
Produce
end
end

If you've never seen Ruby before, this may look like gibberish to you. Here's what this code does:

  1. Provides a description of the path .
  2. User produces to add the app to both the developer portal and the App Store Connect. (19459000) Uses this file create_app .

Woohoo! You have now created your very first lane .

Fastfile and then open Appfile . Remove the pound (#) sign to uncomment the line starting with apple_id Replace [[APPLE_ID]] with your actual Apple ID user name. By entering this information now, you do not have to ask for fastlane several times.

Note : If the App Store Connect and Apple Developer Portal Username are different, replace apple_id line with:

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

Then change each user name holder with their respective user name.

Save Application before closing.

Create your app

Open Terminal inside your project folder and type:

  fastlane create_app

This runs create_app the path that you just created.

You should see something like this:

 output create app

At the top of that output, fastlane suggests that you go ahead of your fastlane command with "bundle exec" to start faster faster in the context of the pearl pile. Continue, you can do it.

Enter the App Store. Connect to a password if prompted. If your developer portal has multiple layers, enter the number corresponding to the team you want to use for the mZone Poker app.

Finally, producing will ask you to enter bundle ID. Time to make one!

The bundle identifier must be different from each other bundle identifier ever used in the App Store Connect. Try entering a unique bundle identifier using the following format:

  com.mZone-Poker. [Insert your email address minus “@” and “.”]

 output creates bundle ID

If the bundle identifier has already been taken, edit it and try again until you have submitted a unique ID.

Then, when asked to submit an app name, it must also be unique. Try using the following format:

  mZone Poker [Insert your email address minus “@” and “.”]

App names cannot be longer than 30 characters, but abbreviated as needed.

If your App Store Connect account has multiple layers, enter the number that corresponds to the team you want to use. [19659002] If you receive errors indicating that there is a problem with your Apple Developer account (for example, if you need to accept a new program agreement), you must correct the problem and run produce again.

If the App name is unavailable, the process will end with an error. Run produce again, enter your Apple ID and the same Bundle ID you just created, then flex your creative muscles to create a unique ID or return to the top of this paragraph and repeat. We know, frustratingly, but we are sure that you will break the infinite loop!

Log in to the Apple Developer Center and the App Store Connect. Voilà! Your app has already been added to both. How cool is that? :]

  developer portal

Apple Developer (over), App Store Connect (below)

Restore Appfile regardless of the line starting with app_identifier and then replacing [[APP_IDENTIFIER]] with the bundle ID you just created.

If you had to choose a team earlier, add the team name so you don't have to re-enter it when running your paths. To enter Developer Portal / App Store Link Team Names, add:

  team_name ("[[TEAM_NAME]]")

Replace [[TEAM_NAME]] with the team name.

Generate Deliverfile

Back in Terminal, type:

  Bundle Exec Fastlane Deliver

When fastlane asks; Would you like to setup? Enter y in response.

Next fastlane will ask, " Would you like to use Swift instead of Ruby? ]" Although, as an iOS developer, you're probably more comfortable working in Swift at the writing of this tutorial, fastlane.swift is still in beta. Then enter n to use Ruby in your fastlane files.

 output deliver

When supplies complete successfully, navigate back to mZone / Fastlane in the Finder and see some new things:

] The catalog metadata that will hold the majority of the app's metadata.

  • Deliverfile that will hold
  • screens directory, which will contain app screens] you will notice a bunch of text files named after common App Store items such as description, keywords, categories etc. fastlane will use these files to send the app's metadata information to the App Store Connect.

    Open ] no-US / description.txt and add:

      mZone is a simple poker calculator for No Limit Texas Hold'em tournaments showing a recommended action program based on your chipt count and the current big blind level.
    

    To keywords.txt add:

      Poker, card, gambling
    

    Confirm that name.txt already contains the name of your app, then add https://www.raywenderlich.com to both privacy_url.txt ] and support_url.txt .

    While this app supports both French and English, only the no-US folder exists. To fix this, make a copy of the folder en-US in the same directory and call it fr-FR . To keep this fastlane tutorial short, you don't have to translate the metadata into French ... this time. ;]

    Next, in the metadata folder:

    • Add Copyright (c) 2019 Razeware LLC to copyright.txt .
    • Add Play Play ] to primary_category.txt .
    • Add Map to primary_first_sub_category.txt .
    • Add Casino to primary_second_sub_category Txt .

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

      {
    "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
    }
    

    This ranking configuration indicates that the app has "frequent / intense" simulated gambling (ie, value = 2) and none of the other listed content. This file gives Apple the information it needs to assign an appropriate age limit.

    And finally, in the folder review_information 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 & # 39; + & # 39; followed by the country code, for example; +44 844 209 0611.

    Congratulations! You have added all the metadata required for submission.

    Note : You can find a complete list of metadata options and Deliverfile settings here.

    Automate screenshots

    Take screenshots can be boring. The more units and languages ​​the app supports, the more hours you burn. Painful!

    mZone Poker supports two languages ​​and two iPhone screen formats. If you had to take five screens per unit for each language and screen format, there would be 20 screens! With fastlane, however, you can do all this by running a single command.

    Set up the snapshot project by entering Terminal:

      fastlane snapshot init
    

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

      # 1 - A list of devices you want to take screenshots from
    devices ([
      "iPhone 8 Plus",
      "iPhone SE"
    ])
    
    # 2 - A list of supported languages
    
    language ([
      'en-US',
      'fr-FR'
    ])
    
    # 3 - The name of the form containing the UI tests
    
    scheme ("mZone Poker UITests")
    
    # 4 - Where should the resulting screens be stored?
    
    output_directory "./fastlane/screenshots"
    
    # 5 - Removes previous screens
    
    clear_previous_screenshots (true)
    

    Here you specify:

    1. The devices you want from fixedlane to capture screenshots.
    2. The localized languages ​​you want to capture.
    3. The name of the Xcode form you will soon create to run
    4. The Output Catalog screen.
    5. This fixed file should remove any screens in the output directory before recording new ones.

    Save the file before closing.

    Return to Terminal and note the instructions that appeared after running fastlane snapshot init :

     output snapshot init

    That's what you should do next.

    Creating a test target

    Open mZone Poker.xcodeproj in Xcode then navigate to File ▸ New ▸ Goal . In the iOS tab Test Test select iOS UI Testing Bundle and then click Next .



    Source link