Xcode 8 Unit Test Error: Failed to determine package identifier for TEST_HOST

I have an Xcode project that does not seem to want to compile my main goal of the application to create the product before trying to use it as the application host when performing unit tests. From Xcode, I am trying to run unit tests with ⌘ + U

I immediately get a dialog saying: Could not determine bundle identifier for [app name] TEST_HOST

(Replace [application name] with the name of the real application)

This dialog box also contains the path to the local derived data directory: "/Users/***/Library/Developer/Xcode/DerivedData/Lowes-aymgdtrbrarmcidtkxoqxeafmxmj/Build/Products/Debug-iphonesimulator/[app name]"

I have unit tests configured with a TEST_HOST setting pointing to $(BUILT_PRODUCTS_DIR)/[app name].app/[app name] . The unit test target has a target dependency on the main purpose of the application. The value of BUNDLE_LOADER is set to $(TEST_HOST) . If you first compile the main application object by pressing ⌘ + B , the correct directory structure and application are created, and then you press ⌘ + U bootstraps and run the unit tests correctly. If I do clean and try again, it will fail immediately. I have never encountered this problem before, and it seems to have arisen after the application was converted to Swift 3. It may or may not have anything to do with the problem, I'm not entirely sure.

I read a few answers here and tried many suggestions, but they don't seem to have the same root problem as mine. For most people, it seems that the host application for "No" and back to the main goal fixes the problem. This does not apply to me.

I tried new checks, reprogrammed the application and tested the targets in Swift 3, as well as the standard clean / clean build / extrude of the received data. None of this has any effect.

Has anyone else experienced this problem and figured out a solution?

+6
source share
3 answers

I have found a resolution for this. This may not apply to all scenarios, but it has been fixed. In the main settings of the project, on the "Information" tab, it is possible to select the configuration to run when the command-line assembly starts. I had a release. By reversing this, Debug fixed my problem.

Xcode project options tab

+13
source

Removing Test Host completely from the Build Settings your test goal will solve this problem.

0
source

It seems that setting "Bundle Loader" in the Release configuration solves the problem.

I can’t fully understand why, but for me this error always appeared in our CI system, where we build from the command line. In the project settings, we set "Use Release to build the command line." Therefore, I think that even if we set the build configuration in Debug through command line arguments, xcodebuild ignores the configuration argument and partially uses the "Release" settings. Perhaps this is a bug with the xcodebuild system (I think it’s worth the radar), if anyone can find a better explanation why this solves the bug I would like to hear about it.

Hope this helps.

0
source

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


All Articles