简体   繁体   中英

Cannot hit breakpoints after “Attach to Process by PID or Name” from a custom “embedded framework” in Xcode 10

I have been trying to debug my objective-c code of a custom embedded framework I have been using/developing for the last years and recently (1-2 weeks ago) just before Xcode 10 was released all worked well. I was able to build my embedded framework with debug configuration, create an app (using NativeScript), deploy it to a simulator, open my framework's .xcodeproject , go to Debug > Attach to Process by PID or Name, select the app and add breakpoints int my objective-c code to debug it.

But today I tried to do the same and the breakpoints cannot be hit. I know my embedded framework is build in debug configuration because the .dSYM file is present. Also after the process is attached if I stop it using the button the app stops in the simulator so it must have attached correctly.

Has anyone faced such issues?

Edit: I did verify that the embedded framework in the project contains debug symbols by comparing the output from nm -a <lib> and nm <lib> from this answer.

Edit 2:

The scenario is quite straight forward:

  1. create an dynamic embedded framework
  2. build its .framework and .framework.dSYS file
  3. add it to a project's embedded frameworks
  4. build that project into app
  5. deploy it to a simulator
  6. open the framework's project
  7. attach it to the process
  8. try to hit a breakpoint.

When you deploy it to the simulator, try stopping the xcode process and manually launch app from the simulator and then attach that Process . Refer to this answer for step by step instructions. How can I debug in a framework in Xcode?

After 3 days of research and digging around I managed to resolve this issue. The source of it still in unknown for me and it looks like it is some sort of breaking change of xcodebuild between 9.4.1 and 10 but it sounds like it could have very much been intentional or a bug fix.

Short answer: Make sure that the .dSYM that you used with your fat library is for the correct device (simulator or a real device)

TL;DR

So the issue was that I was using the wrong .dSYM file when attaching to the simulator while the .dSYM file was taken from the xcodebuild for real device. So the steps in my build phase (done in bash) was the following:

  • Build the framework for simulators
  • Build the framework for real iphones
  • Create a fat library using xcrun using the above created .framework files
  • Copy the .dSYM from the real device location in derived data (this is wrong after XCode 10)

I see that this is incorrect but it never made any issues when doing the "Attach to Process" previously but in XCode 10 this no longer works (using debug symbols created for device with a simulator)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM