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

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

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

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

Tomoki Kobayashi

August 20, 2018
Tweet

More Decks by Tomoki Kobayashi

Other Decks in Technology

Transcript

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

    override func tearDown() { super.tearDown() } func testForScreenshot() { // UI }
  2. // 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()
  3. // // 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() }
  4. UI UI // let screenshot = XCUIScreen.main.screenshot() // let attachment

    = XCTAttachment(screenshot: screenshot) attachment.lifetime = .keepAlways add(attachment)
  5. (1)

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

    4. fastlane snapshot 5. UI Snapshot 6. fastlane snapshot
  7. 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"])
  8. (2)

  9. 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)