ios Xcode 8 Beta - 转换为当前 Swift 语法失败:找不到测试主机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37847807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 8 Beta - Convert to Current Swift Syntax Failed: Could not find test host
提问by thejuki
I am receiving an error message when I try to use Xcode 8's Convert Wizard. After trying rebooting, downloading fresh code, and deleting my DerivedData files I cannot escape this error:
当我尝试使用 Xcode 8 的转换向导时收到一条错误消息。尝试重新启动、下载新代码并删除我的 DerivedData 文件后,我无法逃避此错误:
Convert to Current Swift Syntax Failed: Could not find test host
转换为当前 Swift 语法失败:找不到测试主机
I have tried both options which are: Swift 2.3 and Swift 3. After I select a version I instantly get that error.
我已经尝试了以下两个选项:Swift 2.3 和 Swift 3。在我选择一个版本后,我立即收到该错误。
Here is a screenshot of the error:
这是错误的屏幕截图:
回答by iluvcapra
This worked for me:
这对我有用:
- Select the Xcode project in the lefthand browser.
- Click on your test target in the Project's
General
tab. - Disclose "Testing". In my project the "Host Application" pulldown button was blank. Select your appropriate host application.
- Try building your test target now. If that succeeds then converting syntax should as well.
- 在左侧浏览器中选择 Xcode 项目。
- 单击项目
General
选项卡中的测试目标。 - 披露“测试”。在我的项目中,“主机应用程序”下拉按钮是空白的。选择合适的主机应用程序。
- 立即尝试构建您的测试目标。如果成功,那么转换语法也应该如此。
I had this problem after installing the Xcode 8 beta so I assume this is related.
安装 Xcode 8 beta 后我遇到了这个问题,所以我认为这是相关的。
回答by Oliver Reinhard
回答by Never_be
回答by Scott Nguyen
+1 iluvcapra
+1 伊卢卡普拉
Alternatively, use text editor to remove the following two items from your MyAppSwift.xcodeproj/project.pbxprojfile, search for TEST_HOST
或者,使用文本编辑器从MyAppSwift.xcodeproj/project.pbxproj文件中删除以下两项,搜索TEST_HOST
Now, re-open your project and run the convert wizard again.
现在,重新打开您的项目并再次运行转换向导。
4EFFFAE51B53D5D8003CD25A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "AF SwiftTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "FA SwiftTests";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AF Swift.app/AF Swift";
};
name = Debug;
};
4EFFFAE61B53D5D8003CD25A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = "AF SwiftTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "FA SwiftTests";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AF Swift.app/AF Swift";
};
name = Release;
};
回答by Karthickkck
Please try these Steps:
请尝试以下步骤:
- Select your project on the left side of Xcode.
- Go to Targets and select your Project Tests.
- Select the General Tab and select Host Application drop down and choose your Host Application.
- Convert or Run your project.
- 在 Xcode 的左侧选择您的项目。
- 转到目标并选择您的项目测试。
- 选择常规选项卡并选择主机应用程序下拉菜单并选择您的主机应用程序。
- 转换或运行您的项目。
Trying these steps worked for me.
尝试这些步骤对我有用。
回答by Mark80
In my case I deleted my tests target, then re-added it using the + below targets and selecting "iOs Unit Testing Bundle"
就我而言,我删除了我的测试目标,然后使用下面的 + 目标并选择“iOs 单元测试包”重新添加它
For some reason this got a compile error, so I changed the "Per-configuration Intermediate Build Files Path: for my test target to $(PROJECT_TEMP_DIR)/$(CONFIGURATION) for both debug and release. This allowed the compile to work.
由于某种原因,这出现了编译错误,所以我将“每配置中间构建文件路径:对于我的测试目标更改为 $(PROJECT_TEMP_DIR)/$(CONFIGURATION) 以进行调试和发布。这允许编译工作。
回答by Marmoy
Fix this in 3 steps:
分三步解决这个问题:
- First delete your test target
- The select Edit -> Convert -> To current Swift syntax... and perform the conversion
- Then add a new test target
- 首先删除您的测试目标
- 选择 Edit -> Convert -> To current Swift syntax... 并执行转换
- 然后添加一个新的测试目标