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 state.
My question is, how do I debug the process of a "fresh launch" from a URL? Hitting "Run" in Xcode automatically opens the app. Then, I have to suspend the app to reach Safari and access my test site. But if I close my suspended app, Xcode is no longer attached to it and I'm unable to debug.
These steps can be followed on the device. Founded at this link.
- Run the app from Xcode to install it on your device and then stop it from Xcode.
- Force quit the app from the app switcher UI on the device.
- Navigate to the scheme for the project in Xcode. Under the Run section's Info tab, there is a radio button for "Wait for executable to be launched". Make sure this is checked instead of the "Automatically" option.
- Run the app from Xcode. It will not open on the device, but the debugger will wait for it to open and then it will attach to it.
On the simulator as suggested by Marc-Alexandre Bérubé.
- Run your app on the emulator.
- Force quit the app on the simulator. Press
cmd+shift+(hit h twice)
. Swipe the app up. - Open your terminal and enter this
xcrun simctl openurl booted http://yourdomain/path
.
You need to configure your Xcode app scheme to wait for the app to be launched manually. Here is how you do it: http://blogmobile.itude.com/2013/09/03/how-to-debug-deep-linking-in-ios/.
You then need to copy the launch URL and paste it to Mobile Safari. This will launch your app, and make Xcode get attached to the running app process.
来源:https://stackoverflow.com/questions/18521276/ios-how-to-debug-freshly-launching-an-app-from-a-url