Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug in Xcode

I am trying to debug an iOS app in Xcode. My scheme is with the Build Configuration in Debug. When I run the application, the Debug panel opens but when the application opens in the simulator or on the device, the panel closes and does not allow me to debug.

What are the conditions that must be met in order to debug an application in Xcode?

My Xcode version is 11.3.1. My macOS version is 10.15.2.

Update 1

I put image of my configurations:

enter image description here

When I try to attach the debug to simulator by "Attach to Process by PID or Name..." I have the following error:

enter image description here

enter image description here

like image 675
ffcc Avatar asked Feb 23 '26 01:02

ffcc


2 Answers

The scheme you are running must be enabled for Debugging. This is the default but it might have been changed, by accident, or during experimentation.

Here is a correct example, enabling debug.

enter image description here

Ensure you have set some breakpoints.

Furthermore, it might be that your preference settings are incorrect for debugging.

The following settings need to be checked in Xcode > Preferences; Behaviour Tab.

Note two checked items for the Running Pauses left panel selection:

Behaviour Preferences[1]

Note that when Xcode is installed, upon first use it will prompt for Developer Access to your system requiring a password for the Administrator privileged account (normally your own account has such privilege).

In order for debug attach to work, Developer Mode must be enabled. This can be checked:

# DevToolsSecurity -verbose -status
Getting rights definition for: system.privilege.taskport.debug
Current rights definition dictionary:
"k-of-n" : 1
"class" : "rule"
"created" : 582290628
"version" : 0
"modified" : 589046609
"comment" : "For use by Apple.  WARNING: administrators are advised
            not to modify this right."
"rule" : { "is-admin", "is-developer", "authenticate-developer" }

Developer mode is currently enabled.

To enable developer mode if it is not enabled, use

# sudo DevToolsSecurity -enable

like image 125
Faisal Memon Avatar answered Feb 24 '26 15:02

Faisal Memon


Put breakpoints to your code whatever you want to debug by clicking the number of line.

enter image description here

Hope it helps...

like image 43
Picode Avatar answered Feb 24 '26 14:02

Picode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!