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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:24:38  来源:igfitidea点击:

Xcode 8 Beta - Convert to Current Swift Syntax Failed: Could not find test host

iosxcodexcode8

提问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:

这是错误的屏幕截图:

Xcode 8 Convert Error Message

Xcode 8 转换错误信息

回答by iluvcapra

This worked for me:

这对我有用:

  1. Select the Xcode project in the lefthand browser.
  2. Click on your test target in the Project's Generaltab.
  3. Disclose "Testing". In my project the "Host Application" pulldown button was blank. Select your appropriate host application.
  4. Try building your test target now. If that succeeds then converting syntax should as well.
  1. 在左侧浏览器中选择 Xcode 项目。
  2. 单击项目General选项卡中的测试目标。
  3. 披露“测试”。在我的项目中,“主机应用程序”下拉按钮是空白的。选择合适的主机应用程序。
  4. 立即尝试构建您的测试目标。如果成功,那么转换语法也应该如此。

I had this problem after installing the Xcode 8 beta so I assume this is related.

安装 Xcode 8 beta 后我遇到了这个问题,所以我认为这是相关的。

Picture Credit to @karthikkck enter image description here

图片归功于@karthikkck 在此处输入图片说明

回答by Oliver Reinhard

It cost me a bit of time to find the "Host Application" pulldownmentioned in the otherwise very helpful answer by iluvcapra.

我花了一些时间才找到iluvcapra 在其他非常有用的答案中提到的“主机应用程序”下拉菜单。

So this is what he meant:

所以这就是他的意思:

This is where you find the pulldown menu. Select your main target.

您可以在此处找到下拉菜单。选择您的主要目标。

This is where you find the pulldown menu

This is where you find the pulldown menu

回答by Never_be

I find easy fix for this, just edit your Scheme and disable tests.

我找到了简单的解决方法,只需编辑您的方案并禁用测试即可。

enter image description here

enter image description here

And run conversion again.

并再次运行转换。

回答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

enter image description here

enter image description here

Please try these Steps:

请尝试以下步骤:

  1. Select your project on the left side of Xcode.
  2. Go to Targets and select your Project Tests.
  3. Select the General Tab and select Host Application drop down and choose your Host Application.
  4. Convert or Run your project.
  1. 在 Xcode 的左侧选择您的项目。
  2. 转到目标并选择您的项目测试。
  3. 选择常规选项卡并选择主机应用程序下拉菜单并选择您的主机应用程序。
  4. 转换或运行您的项目。

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:

分三步解决这个问题:

  1. First delete your test target
  2. The select Edit -> Convert -> To current Swift syntax... and perform the conversion
  3. Then add a new test target
  1. 首先删除您的测试目标
  2. 选择 Edit -> Convert -> To current Swift syntax... 并执行转换
  3. 然后添加一个新的测试目标