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. Xcode & fastlane
    iOS
    iOS meetup Nagoya

    View full-size slide

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

    View full-size slide

  3. VanApp
    Fenrir
    Van = Fenrir

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. UI
    Xcode 7 UI Test
    Unit Test UI Test

    View full-size slide

  8. Accessibility Identifier
    UI
    Storyboard Accessibility Identifier

    View full-size slide

  9. class UITestsForScreenshot: XCTestCase {
    override func setUp() {
    super.setUp()
    }
    override func tearDown() {
    super.tearDown()
    }
    func testForScreenshot() {
    // UI
    }

    View full-size slide

  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()

    View full-size slide

  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()
    }

    View full-size slide

  12. UI
    UI
    //
    let screenshot = XCUIScreen.main.screenshot()
    //
    let attachment = XCTAttachment(screenshot: screenshot)
    attachment.lifetime = .keepAlways
    add(attachment)

    View full-size slide

  13. Report Navigator

    View full-size slide

  14. fastlane snapshot
    fastlane iOS/Android
    snapshot
    https://github.com/fastlane/fastlane

    View full-size slide

  15. ( )
    1. UI
    2. UI Accessibility Identifier
    3. UI
    4. fastlane snapshot
    5. UI Snapshot
    6. fastlane snapshot

    View full-size slide

  16. 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"])

    View full-size slide

  17. snapshot
    SnapshotHelper.swift
    UI
    let app = XCUIApplication()
    // snapshot
    setupSnapshot(app)
    // )
    snapshot("01_Connection ")

    View full-size slide

  18. UI
    UI
    app.launchArguments.append("SCREENSHOT")
    ProcessInfo
    ProcessInfo.processInfo.arguments.contains("SCREENSHOT")
    UI

    View full-size slide

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

    View full-size slide

  20. $ fastlane snapshot
    ( + snapshot )

    View full-size slide

  21. fastlane frameit
    (iPhone Plus)
    ( X )

    View full-size slide