构建 Xcode UITest 失败,并显示“错误打开输入文件”

Man*_*uel 2 xcode ios xcode-ui-testing

我在现有的 Xcode 项目中添加了一个 UITest 目标。

记录 UITest 工作正常。但是在构建期间运行相同记录的 UITest 失败并出现错误:

Compile Swift source files
Precompile bridging header
<unknown>:0: error: error opening input file '/Users/<...>/Bridging-Header.h' (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

路径正确,文件存在于路径中。

  • 试图将文件添加到目标,但我无法将它添加到任何目标,因为复选框是灰色的。
  • 试图清理构建文件夹并删除派生数据文件夹,同样的问题。

有任何想法吗?

Man*_*uel 7

解决方案是更改Bridging Header文件的路径。

  1. 选择测试目标,例如 MyAppUITests
  2. 导航到Build Settings> Swift Compiler - General> Objective-C Bridging Header
  3. 替换头文件的现有路径,例如MyApp/MyApp-Bridging-Header.h使用./MyApp/MyApp-Bridging-Header.h. 添加.将允许测试目标找到头文件。