Xcode 6.4 Swift 单元测试无法编译:“未找到 GPUImage.h"“无法导入桥接头" [英] Xcode 6.4 Swift Unit Test Won't Compile: "GPUImage.h not found" "failed to import bridging header"
问题描述
我的 Xcode 项目构建并运行良好.它有 Swift 和 Objective-C 代码.
My Xcode project builds and works fine. It has Swift and Objective-C code.
它安装了 GPUImage.
It has GPUImage installed.
我向它添加了一个单元测试,现在它将不再编译:
未找到GPUImage.h"文件
'GPUImage.h' file not found
无法导入桥接头
以下是我找到并尝试过的解决方法:
Here are the workarounds I have found and tried:
设置产品模块名称以匹配我的项目: 不起作用http://codesheriff.blogspot.co.il/2015/05/importing-swift-code-from-objective-c.html
确保我的构建阶段匹配:不起作用
扩展标题搜索路径:没用https://stackoverflow.com/a/29902874/3324388
这个问题似乎有同样的问题:添加了单元测试目标到 xcode - 未能导入桥接头不会消失
This question seems to have the same issue: added unit testing target to xcode - failed to import bridging header won't go away
如果您知道为什么 XCode 找不到我的 BridgingHeader.h 或 GPUImage.h,请分享.我正在尝试使用 Travis CI 进行单元测试,但无法通过编译步骤.
If you know why XCode can't find my BridgingHeader.h or GPUImage.h then please share. I am trying to get Unit Testing working with Travis CI but can't get passed the compile step.
推荐答案
Xcodebuild
不能正确支持测试目标和应用程序测试.我会尝试 xctool,它是 xcodebuild
的一个不错的替代品,并使它成为更容易测试 iOS 和 OSX 应用程序.Travis CI 已预装.
Xcodebuild
doesn't properly support test targets and application tests. I'd try xctool, which is a nice alternative to xcodebuild
and makes it easier to test iOS and OSX apps. Travis CI comes with it pre-installed.
要在您的机器上本地安装它,您可以使用自制软件.
To install it locally on your machine, you can use homebrew.
update brew
brew install xctool
您可以使用以下命令来构建代码.它的结构与 xcodebuild
相同.
You can use the following command to build your code. Its structure is identical to xcodebuild
.
xctool test -workspace MyExampleProject.xcworkspace -scheme MyExampleTests -sdk iphonesimulator
要在 Travis CI 上运行它,请将以下代码添加到您的 .travis.yml
To run it on Travis CI, add the following code to your .travis.yml
language: objective-c
script:
- xctool -workspace MyExampleProject.xcworkspace -scheme MyExampleProject -sdk iphonesimulator
- xctool test -workspace MyExampleProject.xcworkspace -scheme MyExampleProjectTests -sdk iphonesimulator
这篇关于Xcode 6.4 Swift 单元测试无法编译:“未找到 GPUImage.h"“无法导入桥接头"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!