skip to Main Content

While debugging any iOS application, Xcode builds and run successfully, also launches a simulator but it is not able to attach debugger from Xcode 14 to Simulator iOS app.

It throws an error in Xcode:

enter image description here

Xcode console says:

Could not attach to pid : “75997” Domain: IDEDebugSessionErrorDomain
Code: 3 Failure Reason: attach failed (Not allowed to attach to
process. Look in the console messages (Console.app), near the
debugserver entries, when the attach failed. The subsystem that
denied the attach permission will likely have logged an informative
message about why it was denied.) User Info: {
DVTRadarComponentKey = 855031;
IDERunOperationFailingWorker = DBGLLDBLauncher;
RawUnderlyingErrorMessage = "attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the
debugserver entries, when the attach failed. The subsystem that
denied the attach permission will likely have logged an informative
message about why it was denied.)"; }

Tried with re-installing Xcode and Command line tools, but issue persists.

Steps:

  • Build and run app with Debug executables true
  • Simulator gets launched
  • Error on Xcode and it gets disconnected from simulator

Is there a possibility that it can be blocked by any other app, if so how to identify ?

4

Answers


  1. Chosen as BEST ANSWER

    There was on security software installed in machine which was blocking this simulator to attach.

    To get more information, when we receive that alert we should check in Console.app for our Simulator app process id and notice issues/errors.

    After uninstalling that app, this issue is resolved and able to attach app through debug mode.


  2. I solved the issue by doing the steps below:

    SOLUTION 1:

    1. Edit the scheme
    2. Select Run
    3. Select Build Configuration "Debug"
    4. Select "Wait for the executable to be launched"
    5. Close
    6. Run the app

    see the screenshot here

    You will receive an error message when you run the app again.
    Close the app.
    Edit the scheme again and change "Wait for the executable to be launched" to "Automatically".

    Now your simulator will work as expected.

    SOLUTION 2:

    Delete your app folder in Derived Data
    /Users/[your username]/Library/Developer/Xcode/DerivedData/
    Search your app name folders and delete them.

    SOLUTION 3:

    Open the terminal and run:

    sudo DevToolsSecurity -enable
    

    This command enables the Developer Mode. After running the command you will receive this message: [Developer mode is now enabled].

    Login or Signup to reply.
  3. Sometimes it’s happen, when you are trying to build too fast after a build has started.

    First of all, quit your current simulator, delete derived data and clean the project, wait until whole processing is complete. Then do some changes / editing if required (as we clean all data) and try running on a different simulator.

    Check certificates in key-chain access, if you found any untrusted certificates in key-chain access remove it.

    Also if you are using beta version just make sure it is downloaded from Apple official website.

    Login or Signup to reply.
  4. Came here to share my (strange) solution if anybody crosses the same problem with no answers working. In my case, no solution from this nor other SO answers to similar questions worked (cleaning, rebuilding project, updating, clearing derived data..)

    My setup is:

    Macbook M1 2022 + Xcode Version 14.2 (14C18)

    This Xcode version could not attach to any of my apps (fresh new or previously developed) on different simulators (11, 12, 14) with iOS versions 13.7 – 16.2.

    Editing scheme solution from answer above was not working also so I ended up in leaving scheme as:

    Build configuration: Release
    Debug executable Deselected(!)
    Launch Automatically

    edit scheme window

    And magically debugging app in Xcode started working even though it’s release version with debug option deselected.. Selecting Debug executable again makes Xcode not possible in attaching to app process


    Just to clarify: above steps actually makes app to run as in DEBUG mode – Xcode attaches to pid, I can do console logs and breakpoints. This Xcode version behaves opposite than options selected

    scheme_with_console_logs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search