Problems with iOS test projects
Using the latest xcodegen from Homebrew in this repo https://github.com/igorkulman/iOSSampleApp/ (master branch) with the following config
name: iOSSampleApp
options:
createIntermediateGroups: true
indentWidth: 2
tabWidth: 2
bundleIdPrefix: "sk.kulman"
xcodeVersion: 0940
groupSortPosition: top
targets:
iOSSampleApp:
type: application
platform: iOS
deploymentTarget: "11.0"
sources:
- path: iOSSampleApp
dependencies:
- carthage: RxSwift
- carthage: RxCocoa
- carthage: Swinject
- carthage: SwinjectStoryboard
- carthage: CleanroomLogger
- carthage: SwinjectAutoregistration
- carthage: Reusable
- carthage: RxNuke
- carthage: Nuke
- carthage: FeedKit
- carthage: CRToast
- carthage: RxSwiftExt
- carthage: Defaults
iOSSampleAppTests:
type: bundle.unit-test
platform: iOS
deploymentTarget: "11.0"
sources:
- path: iOSSampleAppTests
dependencies:
- target: iOSSampleApp
- carthage: Quick
- carthage: Nimble
- carthage: RxBlocking
- carthage: RxTest
iOSSampleAppUITests:
type: bundle.ui-testing
platform: iOS
deploymentTarget: "11.0"
sources:
- path: iOSSampleAppUITests
- path: fastlane/SnapshotHelper.swift
dependencies:
- target: iOSSampleApp
Generates the main app OK but the unit tests and UI tests project are not building. I get
Undefined symbols for architecture x86_64:
"protocol witness table for iOSSampleApp.RssSource : Swift.Equatable in iOSSampleApp", referenced from:
closure #1 () -> () in closure #6 () -> () in closure #1 () -> () in iOSSampleAppTests.SourceSelectionViewModelTests.spec() -> () in SourceSelectionViewModelTests.o
trying to run the unit tests.
Looking at the generated iOSSampleAppTests scheme I see BUNDLE_LOADER = "$(TEST_HOST)" and no TEST_HOST.
When I change it to
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/iOSSampleApp.app/iOSSampleAapp";
TEST_HOST = "$(BUNDLE_LOADER)";
as described in http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ the tests start working.
Is it a bug? Or am I missing some setting in my config?
same here
This is fixed in #452
Hey @yonaskolb! We're using the 2.1.0 version installed via homebrew and json variant of the project almost the same as above. But this still doesn't appear to be working?
@yonaskolb
Also ran into this today.
The TEST_HOST was set to $(BUILT_PRODUCTS_DIR)/AppTemplate.app/AppTemplate
AppTemplate is my project name and one of my Target Names.
Xcode only finds it though, when I change to $(BUILT_PRODUCTS_DIR)/Template.app/Template
Template is the product name.
@joshuapoq might be your issue also.
Just to wade in. With the changes made in #452 it resulted in my TEST_HOST not being set correctly.
I'll dig into this further tomorrow but the setup that causes the issue is that I change the PRODUCT_NAME via a .xcconfig file to be the name of the configuration I am building.
// Common.xcconfig
PRODUCT_NAME = $(CONFIGURATION)
This is a quick way of identifying what environment that app was built for.
Changing the product name also changes the name of the products in the BUILT_PRODUCTS_DIR resulting in the unit test target failing to build / run because the value automatically generated via xcodegen is
$(BUILT_PRODUCTS_DIR)/<NAME>.app/<NAME>
A quick fix for me is to set the TEST_HOST in my Common.xcconfig but clearing it out in my Automation.xcconfig
// Common.xcconfig
TEST_HOST = $(BUILT_PRODUCTS_DIR)/$(PRODUCT_NAME).app/${PRODUCT_NAME}
// Automation.xcconfig
TEST_HOST =
@yonaskolb I am having difficulties with my TEST_HOST. The value of the this field is generated using the target name, but the files in Derived data are using the product name.
Is this an open issue or am I configuring something wrong?