简体   繁体   English

从Xcode 10中的自定义“嵌入式框架”“按PID或名称附加到进程”后无法达到断点

[英]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. 我一直在尝试调试过去几年来一直使用/开发的自定义嵌入式框架的Objective-C代码,而最近(1-2周前)在Xcode 10发布之前,它们都运行良好。 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. 我能够使用调试配置构建嵌入式框架,创建应用程序(使用NativeScript),将其部署到模拟器,打开框架的.xcodeproject ,转到“ 调试”>“按PID或名称附加到进程”,选择应用程序并添加断点int我的Objective-C代码进行调试。

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. 我知道我的嵌入式框架是在调试配置中构建的,因为存在.dSYM文件。 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. 编辑:通过比较答案中nm -a <lib>nm <lib>的输出,我确实验证了项目中的嵌入式框架是否包含调试符号。

Edit 2: 编辑2:

The scenario is quite straight forward: 该场景非常简单:

  1. create an dynamic embedded framework 创建一个动态的嵌入式框架
  2. build its .framework and .framework.dSYS file 建立其.framework和.framework.dSYS文件
  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 . 将其部署到模拟器时,请尝试停止xcode进程并从simulator手动启动应用程序,然后附加该Process Refer to this answer for step by step instructions. 有关逐步说明,请参考此answer How can I debug in a framework in Xcode? 如何在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. 它的来源对我来说仍然是未知的,它看起来像是9.4.1和10之间xcodebuild的某种突破性变化,但听起来它可能是非常有意的或是错误修复。

Short answer: Make sure that the .dSYM that you used with your fat library is for the correct device (simulator or a real device) 简短答案:确保与胖库一起使用的.dSYM用于正确的设备(模拟器或真实设备)

TL;DR 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. 因此,问题在于,当我从xcodebuild中获取用于真实设备的.dSYM文件时,我在连接至模拟器时使用了错误的.dSYM文件。 So the steps in my build phase (done in bash) was the following: 因此,在我的构建阶段(在bash中完成)的步骤如下:

  • Build the framework for simulators 构建模拟器框架
  • Build the framework for real iphones 构建真正的iPhone框架
  • Create a fat library using xcrun using the above created .framework files 使用上面创建的.framework文件使用xcrun创建一个胖库
  • Copy the .dSYM from the real device location in derived data (this is wrong after XCode 10) 从真实设备位置复制.dSYM到派生数据中(在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) 我看到这是不正确的,但是以前在执行“附加到进程”时它从未出现任何问题,但是在XCode 10中这不再起作用(使用为模拟器创建的调试符号)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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