iOS App Launch Time – React Native Sample Project

Testing App Launch Time for React Native Sample App – Expo

Create Sample App using Expo

screenshot 2025 03 26 at 12.20.52e280afam
screenshot 2025 03 26 at 12.18.32e280afam

When you create an app using Expo, there are no iOS and Android folder.

Create iOS and Android folder in Expo Sample Project

npx expo prebuild

Setup iOS App Launch Tests

screenshot 2025 04 05 at 5.04.05e280afpm

Add UI Testing Bundle and write a test cases

@MainActor
    func testExample() throws {
        // UI tests must launch the application that they test.
        let app = XCUIApplication()
        app.launch()

        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

    @MainActor
    func testLaunchPerformance() throws {
        if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
            // This measures how long it takes to launch your application.
            let measureOptions = XCTMeasureOptions()
            measureOptions.iterationCount = 10
          measure(metrics: [XCTApplicationLaunchMetric()], options: measureOptions) {
                XCUIApplication().launch()
            }
        }
    }

Results

screenshot 2025 04 05 at 5.28.56e280afpm

I ran 10 times and it’s average launch time is 0.157s (157ms).

Comments

Leave a Reply

Discover more from Shawn

Subscribe now to keep reading and get access to the full archive.

Continue reading