How to debug an app that runs fine on iOS simulator, but crashes on iPhone X? I'm currently building an app with Cordova, and it appears that on the last alpha version, the app only works in the iOS Simulator. When ran on an iPhone X, the app is crashes immediately.

I'm not familiar at all with software development for Apple platform, so I was wondering:


What are my options to understand what is wrong?
Is there some kind of things that I should be aware of to avoid silent crash?


I know we can link an iPhone with the Safari debugger, but I assume this will only work for browser inspection, not app debugging.
You can debug the app by running it on device via Xcode.

First lets get the pre-requisites right. You'll need access to a Mac with recent version of macOS and Xcode installed (preferably latest for each, macOS High Sierra 10.13.6 and Xcode 9.4.1).

After you have your Mac ready, get access to the source code for the app. Open the xcodepoject file for the project file with Xcode. The project file for a project named Sample looks like this in Finder:



Once you have the project open with Xcode, your next step will be to successfully build it. Do it by pressing Shift + Command + r or selecting Product → Build For → Running from the Xcode Menu bar. A successful build (no compilation errors) is indicated by this HUD shown on the desktop:



Next step would be to run on device. Connect your iPhone X to your Mac using the lightning cable. Verify that the device is connected and is recognized by Xcode as will be shown in the run destination selection dropdown in the Xcode toolbar:



Once the device and the app name is selected in the dropdown as shown above, to run the app, click on the play button in the toolbar, or select Product → Run from the Menu bar or use the keyboard shortcut Command + r.

Now the app should launch on your iPhone. Make sure your iPhone is unlocked and both the Mac and iPhone have trusted each other. You will need to add your registered Apple developer ID into Xcode to be able to debug app on device (if not done so already).



Assuming that everything mentioned above is setup correctly, you should be able to launch the app on your iPhone via Xcode and debug it.

Detecting Crash:

As you mentioned that your app is crashing on launch, I am assuming you are getting the build onto device and experiencing it. To pin-point the reason for crash in your apps code, you can take the following steps:


Navigate to the Breakpoint Navigator in Xcode by pressing Command + 8 or selecting View → Navigators → Show Breakpoint Navigator in the Menu bar.
Click on the Create a breakpoint button indicated by + shown in the bottom toolbar area.





Select Exception Breakpoint...





Click outside the popup to dismiss. Make sure that the breakpoint is enabled to be able to catch the reason for crash.


Good luck!