10

We do have troubles getting our CI to work with Xcode. We encounter the issue Could not determine bundle identifier for xxxTest TEST_HOST: some path that does not exist.

What we have done so far:

  • On the CI Machine we are able to run all tests on the device, but if we trigger it with a commit the CI does end in that error.
  • We had that issue on other machines too, when we tried to run the tests of the application. We fixed that by cleaning the machine and reboot the devices.(Had do fix some scheme settings) Not we can run all tests but we run into the issue sometimes without any reason.
  • We also double checked the schemes. The Host Application is set in every Tests scheme to the App itself.

Our project has the following targets:

  • App
  • App Unit Tests
  • App UI Tests
  • AppeareanceKit (Module)
  • AppeareanceKit Unit Tests
  • Models (Module)
  • Models Unit Test

Found solution:

  1. Diabling the Tests except the App UITest
  2. Run the tests once
  3. Enable all Tests
  4. Run the tests

Question:

  • What is happening there? How can we prevent from having that issue over and over again?

Known questions:

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

Tests stop working under xcode 8 TEST_HOST error

Community
  • 1
  • 1
bemeyer
  • 6,154
  • 4
  • 36
  • 86
  • Did you find the solution to this problem? – Giuseppe Lanza Feb 01 '17 at 15:16
  • Not yet. It seems like that it does not compile the app before trying to run the test. So he can't find the ipa file – bemeyer Feb 01 '17 at 15:27
  • @BennX I'm having the exact same issue right now. Compiling the app manually fixes it, but this is obviously not a long term solution. Did you have any luck? – Mark Struzinski Feb 14 '17 at 20:59
  • Actually not yet. Sorry I might go for setup a new project and see if I get t working with a new project. Going to be a bad time because it's a huge project – bemeyer Feb 14 '17 at 21:00

3 Answers3

13

So after ages of having this issue, we could find the right checkbox to fix this issue.

It somehow sounds weird but the issue was the configurations for the command-line builds inside of the Project settings.

enter image description here

I assume this happens because we always test against the debug configuration and it was set to release. Therefore it did the wrong build for the test host.

This does set the defaultConfigurationName inside of the {projectname}.xcodeproject.

Please comment if you have any more insights of this.

bemeyer
  • 6,154
  • 4
  • 36
  • 86
0

In my app I found a solution.

The problem was of course in the test target.

I hope that this solution will work for you too. Go to your test target build settings.

Search for test host.

In my case this testHost was looking like

build/{buildConfigurationName}-iphoneos/{schemeName}.app/{appName}

Which is wrong as the actual path must be

build/{buildConfigurationName}-iphoneos/{schemeName}.app/{schemeName}

so if you have a build configuration called Alpha, in your app named MyApp, with a scheme called MyApp-Alpha the test host path should be

build/Alpha-iphoneos/MyApp-Alpha.app/MyApp-Alpha

it was

build/Alpha-iphoneos/MyApp-Alpha.app/MyApp

I hope this can help... unfortunately this issue appears in many cases.

Giuseppe Lanza
  • 3,519
  • 1
  • 18
  • 40
  • In our project it appears to happen in submodules which take the main project as testhost. ill have a look if that actually looks simelar since we use the "default" host configuration of apple. Maybe thats a crap – bemeyer Apr 07 '17 at 17:00
  • It seems like it does not build the main app at all befor trying to run the tests on it. – bemeyer Apr 07 '17 at 17:07
  • Yes. It was there same for me. Fixing the path for test host key did the trick. And I confirm that for sub modules case it's a crap. – Giuseppe Lanza Apr 07 '17 at 18:11
  • I'll give it a shot on Monday! Cheers – bemeyer Apr 07 '17 at 18:12
  • We do have the configuration set but it still does not build the application up front. If i run one UI test first, it does create the `prodname.app` which ist the test host app. If i run unit test it does not build that app. Any clue? – bemeyer Apr 10 '17 at 08:20
  • I'm afraid not. for me it was enough to fix the path of the test host section. :/ – Giuseppe Lanza Apr 10 '17 at 17:29
0

One reason to have this error is that your info.plist of your target is not in its path. So if you moved it or removed the reference to it, you may get this error.

So if you moved it, put it back into its place or path. if you removed the reference to it, add it again, close and reopen the project.

M. Adam
  • 108
  • 5
Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75