Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tests stop working under xcode 8 TEST_HOST error

Tags:

xcode

ios

xcode8

I want to start tests under Xcode 8 and it fail in the beginning. My error is:

Could not determine bundle identifier for MyProjectTest's TEST_HOST: "/Users/jakubmazur/Library/Developer/Xcode/DerivedData/MyProject-ejeepybggxvekxajlyngopeahiex/Build/Intermediates/CodeCoverage/Products/Testing-iphonesimulator/MyProject.app"

Any idea what's wrong here? I try to clean project - nothing. In the Build Settings in my target in Packaging i change Product Bundle Identifier depends on configuration in my schema. It can have something to do with that, but not sure.

-- EDIT

Ok figure how to narrow the problem. When i change settings in scheme to use Build Configuration Debug instead of Testing seems to work, but I need separate configuration for testing.

like image 444
Jakub Avatar asked Sep 14 '16 14:09

Jakub


4 Answers

For some reason the "Host Application" setting in the picture below was the problem for me. Selecting the proper target fixed this.

This ended up modifying the following values in my xcodeproj:

  • BUNDLE_LOADER = "$(TEST_HOST)";
  • TEST_HOST = "$(BUILT_PRODUCTS_DIR)/myappname.app/myappname";
like image 185
masty Avatar answered Nov 17 '22 03:11

masty


There is one more case you might encounter. If you need different product names for main target(for example Debug, Staging, Production) - and try to use Xcode Host Application selector, it will write incorrect values to TEST_HOST build setting.

And while error message you see is about bundle identifier in Debug configuration, Xcode actually complains about TEST_HOST in Release configuration.

I fixed it by manually changing TEST_HOST build setting. For example, if you have ProductName on main target set to AppDebug in Debug and AppRelease in Release configuration, your TEST_HOST should be following:

What Xcode sets:

$(BUILT_PRODUCTS_DIR)/AppDebug.app/AppDebug

What you need to set:

Debug configuration: $(BUILT_PRODUCTS_DIR)/AppDebug.app/AppDebug
Release configuration: $(BUILT_PRODUCTS_DIR)/AppRelease.app/AppRelease
like image 22
Den Telezhkin Avatar answered Nov 17 '22 02:11

Den Telezhkin


My project has many targets so I had to set the Tests Target's Host Application to 'None'. (Xcode 9.2)

enter image description here

like image 14
mevdev Avatar answered Nov 17 '22 01:11

mevdev


Ok figure it out. There is a problem with naming packages. Unfortunatelly there is some issue with Xcode. I was using different Module Names for different Configurations. So go to Project -> Build Settings -> Product Module Name Change name in all configurations for same name without spaces.

like image 11
Jakub Avatar answered Nov 17 '22 03:11

Jakub