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

Xcode & fastlane で iOS アプリのスクショ撮影を自動化しよう!

0b8ad408b31cb9d5cff2828086c65d58?s=47 temoki
August 20, 2018

Xcode & fastlane で iOS アプリのスクショ撮影を自動化しよう!

Nagoya iOS meetup Vol.4 での発表資料です。
https://nagoya-ios-meetup.connpass.com/event/95974/

0b8ad408b31cb9d5cff2828086c65d58?s=128

temoki

August 20, 2018
Tweet

Transcript

  1. Xcode & fastlane iOS iOS meetup Nagoya

  2. @temoki Fenrir Inc. / PL, iOS Engineer Mobile Act NAGOYA

    /
  3. VanApp Fenrir Van = Fenrir

  4. Fenrir VanApp iOS https://van­app.com/dokidokiglass

  5. Swift (2015 ) Objective­C Swift4 iPhone X

  6. 1. UI 2. UI Accessibility Identifier 3. UI 4.

  7. UI Xcode 7 UI Test Unit Test UI Test

  8. Accessibility Identifier UI Storyboard Accessibility Identifier

  9. class UITestsForScreenshot: XCTestCase { override func setUp() { super.setUp() }

    override func tearDown() { super.tearDown() } func testForScreenshot() { // UI }
  10. // let app = XCUIApplication() app.launch() // UI Accessibility Identifier

    let glassButton = app.buttons["glass-button"].firstMatch let sensorButton = app.buttons["sensor-button"].firstMatch // glassButton.tap() sensorButton.tap()
  11. // // let tap3Button = app.buttons["tap3_button"].firstMatch expectation(for: NSPredicate(format: "exists ==

    true"), evaluatedWith: tap3Button, handler: nil) waitForExpectations(timeout: 30, handler: nil) // 10 for _ in 1...10 { tap3Button.tap() }
  12. None
  13. UI UI // let screenshot = XCUIScreen.main.screenshot() // let attachment

    = XCTAttachment(screenshot: screenshot) attachment.lifetime = .keepAlways add(attachment)
  14. Report Navigator

  15. (1)

  16. None
  17. fastlane snapshot fastlane iOS/Android snapshot https://github.com/fastlane/fastlane

  18. ( ) 1. UI 2. UI Accessibility Identifier 3. UI

    4. fastlane snapshot 5. UI Snapshot 6. fastlane snapshot
  19. fastlane snapshot RubyGems fastlane Xcode snapshot Snapfile, SnapshotHelper.swift $ sudo

    gem install fastlane --verbose $ fastlane snapshot init Snapfile # devices(["iPhone 8","iPhone 8 Plus","iPhone X","iPhone SE"]) # languages(["ja-jP"])
  20. snapshot SnapshotHelper.swift UI let app = XCUIApplication() // snapshot setupSnapshot(app)

    // ) snapshot("01_Connection ")
  21. (2)

  22. None
  23. UI UI app.launchArguments.append("SCREENSHOT") ProcessInfo ProcessInfo.processInfo.arguments.contains("SCREENSHOT") UI

  24. UI ( )

  25. UIViewController view Accessibility Identifier otherElements view // .otherElements view let

    view = app.otherElements["connection-view"].firstMatch // view expectation(for: NSPredicate(format: "exists == true"), evaluatedWith: element, handler: nil) waitForExpectations(timeout: 30, handler: nil)
  26. $ fastlane snapshot ( + snapshot )

  27. fastlane frameit (iPhone Plus) ( X )