Tests stop working under xcode 8 Error TEST_HOST

I want to start tests under Xcode 8, and it does not work at the beginning. My mistake:

Failed to determine the package identifier for MyProjectTest TEST_HOST: "/Users/jakubmazur/Library/Developer/Xcode/DerivedData/MyProject-ejeepybggxvekxajlyngopeahiex/Build/Intermediates/CodeCoverage/Products/Testingappipyprojectsyones

Any idea what's wrong here? I'm trying to clean up a project - nothing. In Build Settings for my purpose in Packaging I change the Bundle identifier of the product, depending on the configuration in my scheme. He may have something to do with it, but he’s not sure.

- EDIT

Good to narrow down the problem. When I change the settings in the circuit to use the Debug assembly configuration instead of Testing , it seems to work, but I need a separate configuration for testing.

+26
source share
10 answers

Good. There is a problem with package names. Unfortunately, there is a problem with Xcode. I used different module names for different configurations. So go to ProjectBuild SettingsProduct Module Name Change the name in all configurations for the same name without spaces.

+8
source

For some reason, the "Host Application" problem in the image below was a problem for me. Choosing the right goal fixed this.

This changed the following values ​​in my xcodeproj:

  • BUNDLE_LOADER = "$ (TEST_HOST)";
  • TEST_HOST = "$ (BUILT_PRODUCTS_DIR) /myappname.app/myappname";
+29
source

There is another case that you may encounter. If you need different product names for the main purpose (for example, Debug, Staging, Production) - and try to use the Xcode Host Application application selector, it will write incorrect values ​​to the TEST_HOST assembly setting.

Although the error message you see is related to the package identifier in the Debug configuration, Xcode actually complains about TEST_HOST in the Release configuration.

I fixed it by manually changing the setting of TEST_HOST. For example, if you have a ProductName for the main target installation in AppDebug in the Debug and AppRelease settings in Release, your TEST_HOST should be as follows:

What Xcode installs:

 $(BUILT_PRODUCTS_DIR)/AppDebug.app/AppDebug 

What you need to install:

 Debug configuration: $(BUILT_PRODUCTS_DIR)/AppDebug.app/AppDebug Release configuration: $(BUILT_PRODUCTS_DIR)/AppRelease.app/AppRelease 
+9
source

There seem to be a few bugs in Xcode8 that can cause this. However, I found a solution for the case where Xcode is trying to find the TEST_HOST application in the Intermediates/CodeCoverage/ folder. (I tried all other solutions with module names, etc., and this did not work for me.)

The problem itself is that Xcode is not even trying to create an application before running the tests. However , when Xcode can find the TEST_HOST in the folder that it will rebuild when the tests run. This is how we can find our way around it.

Two possible solutions:

If you don’t need to have code coverage: Go to the unit test build settings and set Enable Code Coverage Support to No and to disable code coverage in the build setup test setup. (Change scheme, select Test on the left). If you want to run unit tests and get the TEST_HOST error message, try creating ( CMD + B ) or starting the application. Then you can run your tests without this error. Voila.

If you need code coverage: You can follow a specific workaround to populate this Intermediates/CodeCoverage/.. folder. Once the application is inside Xcode, it will be rebuilt for unit tests as it should, but you need to populate it once. Here's how you do it:

  • In the application and unit test, select None for Enable Code Coverage Support.
  • Then, on the General tab of the unit test goal, set the test host application to No
  • Uncheck Allow Host API Validation
  • Try running unit tests. Now Xcode will at least try to build. If Xcode gives a build error (sometimes Xcode complains about Cocoapods here in my experience), try creating one more time.
  • Recheck "Allow Host API Testing" again in unit test target
  • Try the tests again as above. Xcode must complain.
  • Now install the test node in the application.
  • Now the tests should pass. (Until you run clean, you will have to repeat these steps.)

I know this is annoying. But this is the only solution to the problem so far.

+4
source

In Target Audience → Build Settings → Testing → Test Host, you can see the .app file that should be used for testing.

For me, the wrong file name **. app . And I replaced it ** / Build / Intermediates / CodeCoverage / Products / Debug-iphonesimulator / **. App (check that the .app file is present in this directory).

+3
source

What I found is that the tests will not be executed if you did not create and run the same purpose for which you are performing the tests on the device / SIM under test.

For example, if I run tests against the target Production, then I will need to create and run the target Production on the / sim device before I can run the tests. If I didn’t do this, it would give me the same error.

0
source

I often came across this error and eventually found that it was caused by a PRODUCT_NAME change between the Debug and Release build configurations.

We did this so that Debug assemblies had a different application name when installed on the phone (as well as a different package identifier so that we could install them next to the App Store assemblies).

We reverted this change and added the new APP_DISPLAY_NAME parameter to the assembly configuration, varied between assembly types and changed Info.plist to use $ (APP_DISPLAY_NAME) instead of $ (PRODUCT_NAME).

After that, it’s important to enter the test goal in the project and make sure that the “Host application” parameter is generally installed on your application.

0
source

go to xcode Preferenceslocation > Derived preliminary data → choose assembly location Unique

-one
source

This is a bug in Xcode right now. See http://www.openradar.me/28095069 .

-2
source

Exiting Xcode and deleting the DerivedData folder when fixing the problem for me.

 $ sudo rm -Rf Library/Developer/Xcode/DerivedData 

Shame on you, Apple!

-3
source

Source: https://habr.com/ru/post/1014977/


All Articles