2

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.
Vladimir Amiorkov
  • 2,652
  • 3
  • 17
  • 35
  • What does this have to do with Xcode 10? – matt Oct 05 '18 at 14:12
  • That is does not work in Xcode 10 but it did in previous versions of Xcode. Isn't the "xcode" tag for the Apple IDE? – Vladimir Amiorkov Oct 05 '18 at 14:14
  • So it does work in Xcode 9.4.1? Previously you seemed to say it didn’t work there either. Be clear. Does it or not? – matt Oct 05 '18 at 14:19
  • I was able to make it work but installing both XCode 10 after having 9.4.1 made 9.4.1 also experience the same now. I am totally lost at what can be the reason for this. Two weeks ago with 9.4.1 it worked, today with both it does not. – Vladimir Amiorkov Oct 05 '18 at 14:39
  • Well, Xcode 10 functionality does not magically "leak" into Xcode 9. So I put it to you that the talk of Xcode 10 might be a red herring and that something else changed, i.e. something internal to the project. You can easily confirm that by reverting to an older commit. – matt Oct 05 '18 at 15:08
  • A project commit in its objective-c code was not made also it is irrelevant to debugging the entire embedded framework. The only thing that changed was the OS of my mac + XCode :(. – Vladimir Amiorkov Oct 05 '18 at 15:12
  • Well, that sounds like a bug you should report to Apple. – matt Oct 05 '18 at 15:16
  • I have opened a ticket before posting here, hopefully an answer will be found soon :). Just wanted to ask the one place on the internet where real knowledge is shared. Thank you for commenting. – Vladimir Amiorkov Oct 05 '18 at 15:17
  • Well, it would help a lot if you'd provide instructions for reproducing the problem. As it stands, this is just an anecdote. – matt Oct 05 '18 at 15:18
  • I would love to be able, but other than providing you with the steps and scenario I am working with I cannot, the code I am working is internal but the scenario has been observed by colleague of mine that work with the same approach but other embedded frameworks that experience the same when trying to attach and debug. – Vladimir Amiorkov Oct 05 '18 at 15:25
  • I updated my post with "steps to reproduce" – Vladimir Amiorkov Oct 05 '18 at 15:29
  • 1
    I upvoted on that basis :) – matt Oct 05 '18 at 15:35
  • Hi, I just found out why this stopped working with XCode 9.1.4. The framework is build via xcodebuild which is the new one Xcode 10.0 Build version 10A255, meaning that the issue should be in the build framework because of the new XCode – Vladimir Amiorkov Oct 08 '18 at 07:21

2 Answers2

0

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?

cha77a
  • 266
  • 1
  • 3
  • 14
  • Thanks for the suggestion. I did try that but the same "no stopping at breakpoints" happens :( – Vladimir Amiorkov Oct 06 '18 at 12:44
  • The "add and link" the framework to the project option works but I would like to be able to simply open the framework and attach to the process. This bring the convenience of not having to change an apps project, rebuild etc. Still thanks for answering. – Vladimir Amiorkov Oct 08 '18 at 06:52
0

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)

Vladimir Amiorkov
  • 2,652
  • 3
  • 17
  • 35