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

Automatiza tu flow en iOS

Jorge Maroto
November 27, 2015

Automatiza tu flow en iOS

On this talk I'll try to explain all utils which are included on this suite, and how to combine them to save time uploading apps to iTunes Connect, managing provision profiles, etc.

---

Codemotion 2015 talk (http://2015.codemotion.es/agenda.html#5677904553836544/44774004) about how to improve your processes using simple scripts with fastlane tools.

Repo with example: https://github.com/patoroco/fastlane-talk

You can see demo gifs on: https://github.com/patoroco/fastlane-talk/tree/master/deckset_presentation/gifs

Jorge Maroto

November 27, 2015
Tweet

More Decks by Jorge Maroto

Other Decks in Programming

Transcript

  1. Automatiza tu flow en iOS Jorge Maroto García @patoroco

  2. None
  3. None
  4. None
  5. Automatiza tu flow en iOS mobile Jorge Maroto García @patoroco

  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. and more ... https://github.com/fastlane/

  14. Install gem install fastlane

  15. None
  16. fastlane init

  17. None
  18. None
  19. None
  20. Fastfile lane :test do xctest( destination: "name=iPad 2" ) end

  21. DSL

  22. actions fastlane actions

  23. None
  24. Total 120 actions* 4 https://github.com/fastlane/fastlane/ blob/master/docs/Actions.md 4 https://github.com/fastlane/fastlane/ tree/master/lib/fastlane/actions *

    last visit 27/11/2015
  25. None
  26. Example: crashlytics fastlane action crashlytics

  27. None
  28. Example crashlytics lane :crashlytics do ipa( configuration: "Crashlytics" ) crashlytics({

    ipa_path: Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH], groups: "Ticketea", notifications: "YES", notes_path: "./fastlane/crashlytics.txt" }) slack({ message: "Nueva versión de prueba de Box Office", channel: "@javiche", default_payloads: [] }) end
  29. fastlane_version "1.41.1" default_platform :ios platform :ios do desc "Create app

    on iTunes Connect" lane :create_app do # be carefull with produce action, because apps created can't be deleted # from iTunes Connect (thanks Apple) produce( app_identifier: 'me.maroto.codemotion20152', app_name: 'prueba codemotion', language: 'Spanish', app_version: '1.0', sku: 'CODE20155', # if SKU is not specified, it will use a random one ) end desc "Update certificates and use it on provisioning profiles" lane :update_certs do cert sigh(force: true) end ... end https://github.com/patoroco/fastlane-talk/blob/master/fastlane/Fastfile
  30. None
  31. Full flow

  32. None
  33. None
  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. Fastfile lane :create_app do # be carefull with produce action,

    because apps created # can't be deleted from iTunes Connect (thanks Apple) produce( app_identifier: 'me.maroto.codemotion20152', app_name: 'prueba codemotion', language: 'Spanish', app_version: '1.0', sku: 'CODE20155', ) # if SKU is not specified, it will use a random one end
  42. None
  43. None
  44. None
  45. Fastfile desc "Update certificates and use it on provisioning profiles"

    lane :update_certs do cert sigh(force: true) end desc "Enable push if is needed" lane :enable_push do pem sigh(force:true) end
  46. None
  47. Gymfile clean true silent true buildlog_path './fastlane/logs/' output_directory "./fastlane/builds"

  48. Fastfile desc "Create an ipa with Debug configuration" lane :ipa_debug

    do gym( configuration: 'Debug', output_name: 'codemotion-debug.ipa' ) end desc "Create an ipa with Release configuration" lane :ipa_release do gym( configuration: 'Release', output_name: 'codemotion-release.ipa' ) end
  49. None
  50. SnapshotHelper.swift import Foundation import XCTest var deviceLanguage = "" func

    setLanguage(app: XCUIApplication) { Snapshot.setLanguage(app) } func snapshot(name: String, waitForLoadingIndicator: Bool = false) { Snapshot.snapshot(name, waitForLoadingIndicator: waitForLoadingIndicator) } @objc class Snapshot: NSObject { class func setLanguage(app: XCUIApplication) { let path = "/tmp/language.txt" do { let locale = try NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String deviceLanguage = locale.substringToIndex(locale.startIndex.advancedBy(2, limit:locale.endIndex)) app.launchArguments += ["-AppleLanguages", "(\(deviceLanguage))", "-AppleLocale", "\"\(locale)\"","-ui_testing"] } catch { print("Couldn't detect/set language...") } } class func snapshot(name: String, waitForLoadingIndicator: Bool = false) { if (waitForLoadingIndicator) { waitForLoadingIndicatorToDisappear() } print("snapshot: \(name)") // more information about this, check out https://github.com/krausefx/snapshot sleep(1) // Waiting for the animation to be finished (kind of) XCUIDevice.sharedDevice().orientation = .Unknown } class func waitForLoadingIndicatorToDisappear() { let query = XCUIApplication().statusBars.childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other) while (query.count > 4) { sleep(1) print("Number of Elements in Status Bar: \(query.count)... waiting for status bar to disappear") } } }
  51. Snapfile # A list of devices you want to take

    the screenshots from devices([ "iPhone 6", "iPhone 6 Plus", "iPhone 5", "iPhone 4s", ]) languages([ "en-US", "fr-FR", "es-ES" ]) # The name of the scheme which contains the UI Tests scheme "codemotion2015UI" # Where should the resulting screenshots be stored? output_directory "./fastlane/screenshots"
  52. UITest import XCTest class codemotion2015UITests: XCTestCase { override func setUp()

    { super.setUp() let app = XCUIApplication() setLanguage(app) app.launch() } func testSnapshot() { snapshot("01Main") XCUIApplication().buttons.elementBoundByIndex(0).tap() snapshot("02Language") } }
  53. Fastfile lane :generate_snapshots do snapshot( clear_previous_screenshots: true, ) end

  54. None
  55. None
  56. $ frameit https://developer.apple.com/app-store/marketing/guidelines

  57. Main window->English->iPhone 6 Plus

  58. Second window->Spanish->iPhone 5

  59. None
  60. None
  61. Fastfile desc "Runs test with scan" lane :scan do scan(

    scheme: 'codemotion2015', device: 'iPhone 6' ) end
  62. None
  63. None
  64. None
  65. None
  66. Demo

  67. None
  68. Features 4 upload build 4 list builds 4 manage test

    users
  69. None
  70. None
  71. How

  72. None
  73. None
  74. Links 4 fastlane.tools/ 4 github.com/fastlane/*** 4 github.com/fastlane/fastlane/blob/ master/docs/Actions.md

  75. Thanks! Jorge Maroto García @patoroco github.com/patoroco/fastlane-talk