iOS: How to debug “freshly launching” an app from a URL

后端 未结 3 985
时光说笑
时光说笑 2020-12-23 18:53

When launching an app from a URL, there is a distinction between whether the URL is freshly launching an app, or if it\'s resuming an app that has been put into a suspended

3条回答
  •  被撕碎了的回忆
    2020-12-23 19:22

    While the answers that mention activating "Wait for executable to be launched" are good in theory, for various reasons these didn't work for me. On the simulator, though Xcode claimed it had "attached", no logs or breakpoints were ever shown. On-device I was running iOS 13, building from Xcode 10, and using Xcode 11 to load, so I didn't have any debugging symbols. That was more of a personal problem, I suspect on device debugging may have worked.

    What worked best for me was just opening up Console.app on my mac, and using the OSLog APIs to get a solid stream of caveman debugging from the simulator.

    1. Run the app from Xcode on the simulator.
    2. Then immediately quit it on the simulator via the app launched (Cmd-Shift-H * 2)
    3. Launch the app by tapping a deep link I sent to myself via the Messages app
    4. Observe my logs in Console.app

    It's not pretty, but it is highly reliable.

    It's also worth mentioning, that you can protect this useful feature by testing cold start deep-linking via XCUITest. You can call app.terminate in your XCUITests, then open a deep link (typically via a static web page you've setup, I use public GitHub wikis for this) and write tests and assert behaviors just like normal.

提交回复
热议问题