Xcode Instruments error: Allocations tracking library was not loaded in time

Xcode Instruments error: Allocations tracking library was not loaded in time

使用 Instruments 和 allocations instrument 分析独立应用程序目标时,会发生以下情况。

  1. 开始录制
  2. 应用程序立即启动
  3. 仪器显示沙滩球约 10 秒
  4. 应用程序已关闭,Instruments 显示一条错误消息

错误:分配跟踪库未及时加载。

发生错误是因为 Instruments 必须将运行时库注入到正在分析的二进制文件中。为此,Instruments 使用用于 DYLD 的环境变量来注入所述库。最新版本的 macOS 有新的安全措施,可以防止这种类型的注入。

为了解决这个问题,项目需要配置额外的“权利”。为此,请按照下列步骤操作:

  1. 打开您的 Xcode 项目
  2. 显示左窗格
  3. Select 项目导航器 选项卡
  4. Select 你的项目
  5. 在主窗格中,select 签名和功能 选项卡
  6. 在 Hardened Runtime 部分,启用 Allow DYLD Environment Variables 授权
  7. 重建
  8. 简介