更新到 Xcode 10 后,XCUITest 的测试目标似乎无法正常工作

Test target of XCUITest seems not to be working after updating to Xcode 10

我从 Xcode 9.4 更新到 xcode 10,然后在尝试 运行 我的 UI 测试时似乎没有任何效果。测试应用程序加载了一段时间然后测试失败,尽管构建在测试之前已成功完成。 并且源代码也成功构建,我可以 运行 模拟器上的应用程序。

错误是:

Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: The test runner failed to load the test bundle. Executable cannot be loaded for some other reason, such as a problem with a library it depends on or a code signature/entitlements mismatch.))

首先,如果您使用的是 Cocoapods,请确保您的测试目标设置了继承的搜索路径,例如:

# MARK: Common pods
abstract_target 'AppCommon' do
  pod 'Alamofire'

  target 'MyFrameworkA' do
    project './MyPath/MyFrameworkA/MyFrameworkA.xcodeproj'

    target 'MyFrameworkATests' do
      inherit! :search_paths
    end
  end
end

接下来,在 FrameworkA构建阶段 中,确保任何其他框架(A 中使用的 B、C),设置为 目标依赖项 并添加到 链接二进制库 .

最后,确保您的 FrameworkATests 目标在 [=20= 中有您的 FrameworkA ]Target Dependencies 并添加到 Linked Binary With Libraries 阶段。

Xcode 10 引入了新的构建系统,它并行化了大部分构建讨论,包括依赖项。新的构建系统可以检测到大部分配置问题。必须有异常配置的项目开始失败,新的构建系统已经检测到这一点。关于构建系统你应该知道的所有事情 https://www.xcteq.co.uk/xcblog/five-things-you-must-know-about-xcode-10-new-build-system/