Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fastlane: from 0 to hero

Avatar for Julien Quéré Julien Quéré
September 22, 2017

Fastlane: from 0 to hero

When we are an iOS developer, there are a lot of repetitive and tedious tasks to release our apps. But doing these same boring things over and over again is just madness.

During this classroom we saw how we can automate all these boring and repetitive tasks with fastlane. This classroom was a part of Frenchkit 2017.

All the resources of this classroom are available on github: https://github.com/FrenchKit/FastlaneClassroom

Avatar for Julien Quéré

Julien Quéré

September 22, 2017
Tweet

More Decks by Julien Quéré

Other Decks in Technology

Transcript

  1. fastlane is the tool to release your iOS app !

    It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application. FASTLANE, FROM 0 TO HERO fastlane?
  2. fastlane is the tool to release your iOS and Android

    app ! It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application. FASTLANE, FROM 0 TO HERO fastlane?
  3. FASTLANE, FROM 0 TO HERO Build Certificates and provisioning Screenshots

    automation Send metadata and binaries A bunch of tools
  4. FASTLANE, FROM 0 TO HERO ▸ 170+ plugins ▸ Ruby

    DSL == Your own code ▸ Any shell / Ruby scripts But there is more!
  5. FASTLANE, FROM 0 TO HERO ▸ Defines all the steps

    to execute your tasks Fastfile?
  6. FASTLANE, FROM 0 TO HERO ▸ Defines all the steps

    to execute your tasks Fastfile?
  7. FASTLANE, FROM 0 TO HERO ▸ Defines all the steps

    to execute your tasks Fastfile?
  8. FASTLANE, FROM 0 TO HERO ▸ Everything starts with fastlane

    init ▸ Read the logs, they are friendly ▸ Read https://codesigning.guide Release it!
  9. FASTLANE, FROM 0 TO HERO Snapshot 5 screens 5 devices

    X "#$%& 5 languages X = 125 screenshots '
  10. FASTLANE, FROM 0 TO HERO ▸ Based on Xcode UI

    Tests (which relies on UIAccessibility) ▸ 2 separate processes ▸ Cannot interact directly with your code ▸ Use the record mode ! Snapshot
  11. FASTLANE, FROM 0 TO HERO ▸ Based on Xcode UI

    Tests (which relies on UIAccessibility) ▸ 2 separate processes ▸ Cannot interact directly with your code ▸ Use the record mode ! Snapshot
  12. FASTLANE, FROM 0 TO HERO ▸ Build and Run (⌘+R)

    ▸ open EmojiUITests.swift ▸ Lauch record mode ▸ Select an emoji and press back UITests git clone https://ios117.com/emojikit
  13. FASTLANE, FROM 0 TO HERO UITests git checkout step1 func

    testExample() { let app = XCUIApplication() // TODO: Lauch Screenshot let emojislistCollectionView = app.collectionViews["emojisList"] emojislistCollectionView.cells["1F60E"].tap() // TODO: Cool screenshot backButton()?.tap() emojislistCollectionView.cells["1F603"].tap() // TODO: Proud screenshot backButton()?.tap() }
  14. FASTLANE, FROM 0 TO HERO Snapshot time fastlane snapshot init

    ▸ Follow the guide ▸ Replace every //TODO by the real snapshot call ▸ Edit Snapfile to limit the devices matrix ▸ "iPhone 6”, "iPhone 6 Plus”, "iPad Air 2” ▸ “en-US","fr-FR"
  15. FASTLANE, FROM 0 TO HERO Snapshot time git checkout step2

    devices([ "iPhone 6", "iPhone 6 Plus", "iPad Air 2" ]) languages([ "en-US", "fr-FR" ]) func testExample() { let app = XCUIApplication() snapshot("0-Launch") // We are looking for the collectionView let emojislistCollectionView = app.collectionViews["emojisList"] // Then, we tap on the 1F60E cell (1F60E is the code of the "cool" emoji) emojislistCollectionView.cells["1F60E"].tap() snapshot("1-Cool") // Press the UINavigationBar back button backButton()?.tap() // Tap the 1F603 cell (1F60E is the code of the "Proud" emoji) emojislistCollectionView.cells["1F603"].tap() snapshot("2-Proud") backButton()?.tap() } Snapfile EmojiUITests.swift
  16. FASTLANE, FROM 0 TO HERO ▸ Create a screenshot lane

    ▸ Step 1: a slack message saying that we start ▸ Step 2: launch snapshot ▸ Step 3: a slack message saying that it’s done ▸ Use the slack action ▸ Need to define the SLACK_URL Slack fastlane action slack open SLACKURL.txt
  17. FASTLANE, FROM 0 TO HERO Slack git checkout step3 before_all

    do ENV["SLACK_URL"] = “https://hooks.slack.com/services/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" ENV["FL_SLACK_USERNAME"] = "Caprica Six" ENV["FL_SLACK_ICON_URL"] = "http://ios117.com/images/bot.png" ENV["FL_SLACK_DEFAULT_PAYLOADS"] = "" end desc "Run snapshots" lane :screenshots do slack(message: "(\nStarting screenshot generation") snapshot slack(message: ")\nScreenshots generated. Just by pressing 1 button !") end Fastfile
  18. FASTLANE, FROM 0 TO HERO Slack def count_generated_screenshots output_dir =

    File.expand_path(File.join("../", ENV["SNAPSHOT_OUTPUT_DIRECTORY"])) Dir[File.join(output_dir, '**', '*.png')].count { |file| File.file?(file) } end Fastfile desc "Run snapshots" lane :screenshots do slack(message: "(\nStarting screenshot generation") snapshot slack(message: ")\n*#{count_generated_screenshots()}* screenshots generated. Just by pressing 1 button !") end ▸ Bonus: show screenshots count
  19. FASTLANE, FROM 0 TO HERO Slack Fastfile error do |lane,

    exception| slack( message: "*\nUh oh, we had an error with lane #{lane}:\n#{exception.message}\n\n¯\\_(ϑ)_/¯", success: false ) end ▸ Bonus: show errors
  20. FASTLANE, FROM 0 TO HERO ▸ fastlane can do everything

    ! ▸ Feel free to read “Would you like to know more ?” in the README ▸ Questions ? ▸ Ask me now ▸ Ask me during the conference ▸ Ping me on Twitter: @juli1quere To sum up