118

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:

Convert to Current Swift Syntax Failed: Could not find test host

I have tried both options which are: Swift 2.3 and Swift 3. After I select a version I instantly get that error.

Here is a screenshot of the error:

Xcode 8 Convert Error Message

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
thejuki
  • 1,351
  • 2
  • 13
  • 16
  • I have the same issue here. Another, smaller, project converts fine. – Gondomir Jun 16 '16 at 11:21
  • I am not sure what could be causing it. It lets me select the modules to convert. All modules produce the same error. – thejuki Jun 16 '16 at 12:24
  • What is the "test host"? It shows the file DerivedData/ding/Build/Products/Debug-iphoneos/ding.app/ding which does not exist after Deleting DerivedData folder. – Gondomir Jun 16 '16 at 13:22
  • You can also check on Swift language version on the Build settings. Try to use a lower version of it. – iPhoneDeveloper Nov 05 '17 at 06:31

7 Answers7

313

This worked for me:

  1. Select the Xcode project in the lefthand browser.
  2. Click on your test target in the Project's General tab.
  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.

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

Picture Credit to @karthikkck enter image description here

Sandeep Rana
  • 3,251
  • 2
  • 24
  • 38
iluvcapra
  • 9,436
  • 2
  • 30
  • 32
  • 5
    That worked for me. Thanks! For clarification: Click and select your test target on the selector to the left of the General tab title. – thejuki Jun 17 '16 at 16:29
  • 6
    Thanks, worked for me too. Noting here a crazy detail that may help others too: the "Host Application" field already had the correct value filled, but just toggling it off and back to its original value made it work. – mz2 Jun 30 '16 at 20:06
  • 5
    For what it's worth my Host Application was set to "custom". Changing to the only available option fixed the issue. Thanks! – Mark McCorkle Sep 08 '16 at 12:23
  • Thanks. It worked on the Xcode 8 official released version too – Bharathi Sep 16 '16 at 12:49
  • 1
    Where to find the one mentioned in step 3? @Bharathi – JayVDiyk Sep 22 '16 at 03:06
  • 2
    I don't have a testing section in my general tab?? – Deuce bigalow Oct 26 '16 at 00:09
  • This has happened on every single project of mine, and the solution above fixes it every time. Xcode is so frustrating at times... this is basically a bug - or at the very least there should be more helpful directions. – HughHughTeotl Oct 27 '16 at 09:28
  • The solution worked for me, however, it wasn't eloquently written and confused me for a while, I ended up checking the general tab under preferences, @thejuki clarification is what helped me – Mthokozisi Apr 18 '17 at 10:51
  • I did this still the error is same, when doing it from Swift 3.1 to Swift 4 – Rocky Balboa Jul 18 '17 at 11:28
62

It cost me a bit of time to find the "Host Application" pulldown mentioned in the otherwise very helpful answer by 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

thejuki
  • 1,351
  • 2
  • 13
  • 16
Oliver Reinhard
  • 629
  • 5
  • 3
23

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

enter image description here

And run conversion again.

Never_be
  • 839
  • 2
  • 10
  • 20
  • 1
    thanks! this worked for me, while the accepted answer did not. – daver Nov 25 '16 at 06:19
  • This. Even though I already had the "Host Application" properly set, it didn't work. Neither could I run the tests (getting the same error message...). the project doesn't actively use unit tests right now, but will have to look into that at some point... – Nicolas Miari Sep 06 '18 at 02:22
5

+1 iluvcapra

Alternatively, use text editor to remove the following two items from your MyAppSwift.xcodeproj/project.pbxproj file, search for 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;
    };
Scott Nguyen
  • 77
  • 1
  • 1
5

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.

Trying these steps worked for me.

thejuki
  • 1,351
  • 2
  • 13
  • 16
Karthick C
  • 1,519
  • 17
  • 16
0

In my case I deleted my tests target, then re-added it using the + below targets and selecting "iOs Unit Testing Bundle"

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.

Mark80
  • 55
  • 1
  • 7
-1

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
Marmoy
  • 8,009
  • 7
  • 46
  • 74