【问题标题】:iOS unit tests failing with invalid XCTest bundle errors on M1iOS 单元测试因 M1 上的无效 XCTest 包错误而失败
【发布时间】:2021-12-18 21:14:51
【问题描述】:

在 M1 机器上运行单元测试时,会生成一些捆绑错误,并立即使测试套件崩溃。

具体来说:

  • 未能加载测试包
  • 找不到合适的图片
  • 试图加载未签名的库
2021-11-04 08:53:33.378375-0600 xxx[81944:1274939] Failed to load test bundle from file:///Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit%20Tests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found.  Did find:
    /Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests, NSDebugDescription=dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found.  Did find:
    /Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library, NSBundlePath=/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest, NSLocalizedDescription=The bundle “Unit Tests.xctest” couldn’t be loaded because it is damaged or missing necessary resources.}
2021-11-04 08:53:33.683690-0600 xxx[81944:1274939] The bundle “Unit Tests.xctest” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2021-11-04 08:53:33.683757-0600 xxx[81944:1274939] (dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found.  Did find:
    /Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library)

相同的单元测试在基于 Intel 的 Mac 上按预期运行。

【问题讨论】:

    标签: ios xcode unit-testing


    【解决方案1】:

    结果是生成了一个导致解决方案的微妙警告。

    在单元测试目标的构建设置中,在打包下,如果您打开“生成 Info.plist 文件”或手动指定 Info.plist,则可以解决此问题。

    【讨论】:

      猜你喜欢
      • 2013-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 2021-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多