尽管所有构建设置相反,Xcode Instruments 仍在剥离符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11217673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:41:45  来源:igfitidea点击:

Xcode Instruments is stripping symbols despite all build settings to the contrary

xcodeinstrumentssymbolsstripping

提问by jaredsinclair

Problem

问题

Instruments' Time Profiler is stripping all symbols except system libraries from my app, despite the fact that I have disabled this behavior in all relevant build settings in Xcode — but only on one development machine.The other dev machine behaves normally.

Instruments 的 Time Profiler 正在从我的应用程序中剥离除系统库之外的所有符号,尽管我在 Xcode 的所有相关构建设置中禁用了此行为 -但仅在一台开发机器上。另一台开发机器运行正常。

Description

描述

Instruments' Time Profiler is stripping all symbols except system libraries, despite the fact that I have disabled this behavior in all relevant build settings in Xcode — but this is only happening on one of my development machines. I have two development machines running the same version of OS X, Xcode, and Instruments, and each machine is using an identical copy of the same Xcode project with identical build settings, schemes, and other configurations, and the app is profiled using the same test device (iPhone 4S with the latest public version of iOS 5).

Instruments 的 Time Profiler 正在剥离除系统库之外的所有符号,尽管我在 Xcode 的所有相关构建设置中禁用了此行为——但这仅发生在我的一台开发机器上。我有两台运行相同版本的 OS X、Xcode 和 Instruments 的开发机器,每台机器都使用相同 Xcode 项目的相同副本,具有相同的构建设置、方案和其他配置,并且应用程序使用相同的测试设备(装有最新公开版 iOS 5 的 iPhone 4S)。

Machine 1
- Mac OS X 10.7.4
- Xcode 4.3.2 (4E2002)
- Instruments 4.3 (4321)

机器 1
- Mac OS X
10.7.4 - Xcode 4.3.2 (4E2002)
- 仪器 4.3 (4321)

Machine 2
- Mac OS X 10.7.4
- Xcode 4.3.2 (4E2002)
- Instruments 4.3 (4321)

机器 2
- Mac OS X
10.7.4 - Xcode 4.3.2 (4E2002)
- 仪器 4.3 (4321)

Steps To Reproduce

重现步骤

  1. Open included sample project on each machine.
  2. Make sure the iPhone 4S is selected as the test device.
  3. Select Product > Profile
  4. When Instruments launches, select Time Profiler and continue.
  5. Run the app.
  6. Notice how the symbols are stripped when running on the iMac (Machine 1) but not on the MacBook Air (Machine 2).
  1. 在每台机器上打开包含的示例项目。
  2. 确保选择 iPhone 4S 作为测试设备。
  3. 选择产品 > 简介
  4. 当 Instruments 启动时,选择 Time Profiler 并继续。
  5. 运行应用程序。
  6. 请注意在 iMac(机器 1)上运行时符号是如何被剥离的,但在 MacBook Air(机器 2)上没有。

Expected Behavior

预期行为

Symbols from my own code should appear in the Time Profiler on both machines.

我自己的代码中的符号应该出现在两台机器上的 Time Profiler 中。

Regression

回归

I have tried all of the following, with no change in the actual results:

我已经尝试了以下所有方法,但实际结果没有变化:

  1. Rebooting the machine.

  2. Trying other Xcode projects

  3. Deleting the "Derived Data" for all projects in the Xcode Organizer.

  4. Re-symbolicating the document in Instruments (carefully selecting the correct DSYM file in ~/Library/blahBlahBlah…)

  1. 重新启动机器。

  2. 尝试其他 Xcode 项目

  3. 删除 Xcode Organizer 中所有项目的“派生数据”。

  4. 在 Instruments 中重新符号化文档(在 ~/Library/blahBlahBlah... 中仔细选择正确的 DSYM 文件)

Final Notes

最后的笔记

Here is a link to a .zip file of a sample project: Sample Project .zip

这是示例项目的 .zip 文件的链接:示例项目 .zip

采纳答案by jaredsinclair

I was finally able to get it to work by a method that's just shy of a nuke-and-pave scenario:

我终于能够通过一种几乎没有核弹铺路场景的方法让它工作:

  1. Make absolutely sure all symbol stripping is disabled for your current build configuration. Make sure you've done this for your Release config if that's what's being profiled for Instruments.
  2. Delete the app from the iOS device.
  3. Restart the iOS device.
  4. Restart the Mac (I don't trust Xcode or Lion at allto quit all relevant processes otherwise).
  5. Launch Xcode, go to Organizer > Projects and delete Derived Data for the affected project.
  6. Clean your project. Hell, why not?
  7. Build and profile for Instruments.
  8. Choose the Time Profiler in Instruments for clarity.
  9. The first run will notshow the symbols, but don't quit. Leave Instruments running!
  10. Re-symbolicate the document in Instruments, navigating carefully to the correct dSYM file for the current build. This should be easier since you've deleted the derived data in step 5.
  11. Now you should be able to see your symbols. It helps if you hide non-objective-C symbols.
  1. 绝对确保为您当前的构建配置禁用所有符号剥离。如果这是为 Instruments 配置的,请确保您已为您的 Release 配置完成此操作。
  2. 从 iOS 设备中删除该应用程序。
  3. 重新启动 iOS 设备。
  4. 重新启动MAC(我不信任的Xcode或狮子在所有以其他方式退出所有相关过程)。
  5. 启动 Xcode,转到 Organizer > Projects 并删除受影响项目的派生数据。
  6. 清理你的项目。地狱,为什么不呢?
  7. 为仪器构建和配置文件。
  8. 为清楚起见,选择 Instruments 中的 Time Profiler。
  9. 第一次运行不会显示符号,但不要退出。让仪器运行!
  10. 在 Instruments 中重新符号化文档,仔细导航到当前构建的正确 dSYM 文件。这应该更容易,因为您已在步骤 5 中删除了派生数据。
  11. 现在您应该能够看到您的符号了。如果您隐藏非目标 C 符号,它会有所帮助。

Why do I suggest that you delete the app and restart the iOS device in Steps 2 and 3? I have a suspicion that Xcode doesn't perform a clean installation of each build, but may install deltas, such that the symbol addresses present in Instruments are a mixture of the current build plus previous builds. If so, then this issue is even more common for someone like me, who shares a single test device between more than one Mac. This assumption could be wildly incorrect.

为什么我建议您在步骤 2 和步骤 3 中删除应用程序并重新启动 iOS 设备?我怀疑 Xcode 不会对每个构建执行全新安装,但可能会安装增量,因此 Instruments 中存在的符号地址是当前构建和以前构建的混合。如果是这样,那么对于像我这样在多台 Mac 之间共享一个测试设备的人来说,这个问题就更常见了。这个假设可能非常不正确。

If the above steps don't work for you, please let me know in the comments. I'd like to create a detailed radar report at some point in the future.

如果以上步骤对您不起作用,请在评论中告诉我。我想在未来的某个时候创建​​一份详细的雷达报告。

回答by Flavien Volken

I'm not sure that it has been fixed in the 4.3 but this is a known problem in 4.2 seen here

我不确定它是否已在 4.3 中修复,但这是 4.2 中的一个已知问题,见此处

Instruments There is a known issue with the Profile action from Xcode 4.2. After a build in which no source files have changed, Instruments will be unable to gather symbols for the target application.

仪器 Xcode 4.2 中的 Profile 操作存在一个已知问题。在没有更改源文件的构建之后,Instruments 将无法为目标应用程序收集符号。

This affects projects where both:

这会影响以下两个项目:

  1. The Release configuration is selected for the Profile action. (default)
  2. The Strip Linked Product build setting is set to "Yes”, or a custom Run Script build phase strips the product. (non-default)
  1. 为 Profile 操作选择了 Release 配置。(默认)
  2. 剥离链接产品构建设置设置为“是”,或者自定义运行脚本构建阶段剥离产品。(非默认)

The workaround is to do any one of the following:

解决方法是执行以下任一操作:

  1. Perform a "Clean" on the product before initiating the Profile action.
  2. Do a Clean of the product and temporarily set the Strip Linked Product build setting to "No" while Profiling.
  3. Set the configuration of the Profile action to Debug.
  4. Run successive profiles directly from within Instruments when you do not need to rebuild. When developing Mac apps, using the GC Monitor template in Instruments may cause Instruments to crash. To workaround the problem please consider migrating your application to ARC.
  1. 在启动配置文件操作之前对产品执行“清洁”。
  2. 清理产品并在分析时暂时将剥离链接产品构建设置设置为“否”。
  3. 将 Profile 操作的配置设置为 Debug。
  4. 当您不需要重建时,直接从 Instruments 运行连续的配置文件。在开发 Mac 应用程序时,在 Instruments 中使用 GC Monitor 模板可能会导致 Instruments 崩溃。要解决此问题,请考虑将您的应用程序迁移到 ARC。

回答by Fredrik Johansson

I've had a similar problem for days. I was able to profile the Debug configuration, but not Release. First I tried to make a copy of the release configuration (as suggested somewhere on the web), but that copy did not work either.

我已经有类似的问题好几天了。我能够分析调试配置,但不能分析。首先,我尝试制作发布配置的副本(如网上某处建议的那样),但该副本也不起作用。

Then I made a copy of Debug, called it Profile, tried it and the symbols of Profile were shown in the profiler. Great! I then changed the optimization levels etc. to the same as Release, and now it works! Just wanted to share this, as this comment would have spared me hours...

然后我复制了一份Debug,叫它Profile,试了一下,Profile的符号显示在profiler中。伟大的!然后我将优化级别等更改为与 Release 相同,现在它可以工作了!只是想分享这个,因为这个评论会让我节省几个小时......

回答by Thiago

I had a similar issue where I had no symbols in my os x application that I built from the command line (so in this case it is not an iphone or xcode issue). It turned out the problem was due to a bad DYLD_LIBRARY_PATH that contained my PATH. When I got rid of all those non-library paths, such as /usr/bin/, it worked.

我有一个类似的问题,我从命令行构建的 os x 应用程序中没有符号(所以在这种情况下它不是 iphone 或 xcode 问题)。结果证明问题是由于包含我的 PATH 的 DYLD_LIBRARY_PATH 错误造成的。当我摆脱所有那些非库路径(例如 /usr/bin/)时,它起作用了。

回答by Jake T.

I have a lot of third party frameworks whose symbols and binaries are unfortunately getting lost.

我有很多第三方框架,它们的符号和二进制文件不幸丢失了。

Additionally, my app's binary was getting lost.

此外,我的应用程序的二进制文件丢失了。

I.e. if I selected File > Symbols, clicked my target, and found the similarly named item, the Binary Path was showing up red.

即,如果我选择“文件”>“符号”,单击我的目标,并找到名称相似的项目,则二进制路径显示为红色。

The solution was to go to Instruments > Preferences > Symbols, and add /Users/<MY_USER>/Library/Developer/Xcode/DerviedDatato the search paths. Libraryis not indexed by Spotlight. After doing this, I have at least had the symbols for my app. The little circle next to my app's name goes from Yellow to Green when I do this, and persists between restarting Instruments, unlike other solutions to manually set the binary.

解决方案是转到 Instruments > Preferences > Symbols,然后添加/Users/<MY_USER>/Library/Developer/Xcode/DerviedData到搜索路径中。Library未被 Spotlight 编入索引。这样做之后,我至少有我的应用程序的符号。当我这样做时,我的应用程序名称旁边的小圆圈从黄色变为绿色,并且在重新启动 Instruments 之间持续存在,这与手动设置二进制文件的其他解决方案不同。

Let me know if you can tell me how to get all the ones for my third party frameworks. I use Carthage for some, others installed manually. Have had no luck with these yet.

如果您能告诉我如何为我的第三方框架获取所有这些,请告诉我。我使用 Carthage 安装一些,其他手动安装。还没有这些运气。

回答by Raj Pawan Gumdal

Have been facing the same and stumbled upon this thread.

一直面临同样的问题,偶然发现了这个线程。

I realized that I first profiled the app with release build and after changing the scheme in Xcode for the same app, the profiler was still unable to symbolize. I have tried all obvious solutions you mentioned above but in vain.

我意识到我首先使用发布版本对应用程序进行了分析,在 Xcode 中为同一个应用程序更改方案后,分析器仍然无法符号化。我已经尝试了你上面提到的所有明显的解决方案,但都是徒劳的。

The profiler somehow is still referring to the first build (release build)'s settings and hence it is not able to symbolize. So, I just changed the app's bundle identifier for testing purpose so that a new app is created altogether for profiling purpose. I could check the code where leaks exist now.

探查器以某种方式仍然指的是第一个构建(发布构建)的设置,因此它无法符号化。因此,我只是出于测试目的更改了应用程序的包标识符,以便完全创建一个新应用程序用于分析目的。我现在可以检查存在泄漏的代码。

Try it out and let me know if this works for you too. Still pondering over why Instruments is failing to symbolize though.

试试看,让我知道这是否也适合你。仍在思考为什么 Instruments 没有符号化。

回答by CReaTuS

Try open XCode 3 and him Organizer. And try add from this Organizer a devices to both machines.

尝试打开 XCode 3 和他的管理器。并尝试从此管理器向两台机器添加设备。

Just open Organizer and wait him processes. If you're see a button "Use for development" then click him.

只需打开管理器并等待他处理。如果您看到“用于开发”按钮,请单击它。

Sometimes, XCode 4 can't add a device a truely for full development.

有时,XCode 4 无法真正为完整开发添加设备。