Hive
Framework was not compiled for testing if I add custom Configuration
GitHub issue · Open
What problem or need do you have?
Hi all I’ve faced with very strange issue during splitting big monolith project on submodules. I’m trying to build EventTracking framework and add tests to it.
we have a several different servers that need to be configured with different Configurations = .debug(name: "Develop-Debug"), .debug(name: "Stage-Debug")... etc.
We have a separated framework for network management and some additional helpers(named Internal_Framework_With_Helpers and Internal_Networking_Framework accordingly)
Both Project.swift files for frameworks(Internal_Framework_With_Helpers and Internal_Networking_Framework) also contains whole list of custom configurations.
All projects generates and builds successfully without errors.
BUT when I try to write some test for EventTracking submodule and add @testable macro to import EventTracking I’m got error Module ‘EventTracking’ was not compiled for testing
I’ve tried to remove custom configurations from EventTracking submodule’s Project.swift file and generate project.
In this case I’m NOT got error Module ‘EventTracking’ was not compiled for testing
But my whole project stop building at all and I’m receiving a lot of errors
Here is an my EventTracking submodule Project.swift file
let project = Project(
name: "EventTracking",
organizationName: "com.organizationName",
options: .options(
automaticSchemesOptions: Project.Options.AutomaticSchemesOptions.enabled(
targetSchemesGrouping: .byNameSuffix(
build: [
"",
"Interface",
"Testing"
],
test: ["Tests"],
run: []
),
codeCoverageEnabled: true,
testingOptions: []
)
),
settings: .settings(
base: [
"OTHER_LDFLAGS": "$(inherited) -ObjC"
],
configurations: [
.debug(name: "Develop-Debug"),
.debug(name: "Stage-Debug"),
.debug(name: "Prod-Debug"),
.debug(name: "Test1-Debug"),
.debug(name: "Test2-Debug"),
.debug(name: "Test3-Debug"),
.debug(name: "Test4-Debug"),
.release(name: "Develop-Release"),
.release(name: "Stage-Release"),
.release(name: "Prod-Release"),
.release(name: "Test1-Release"),
.release(name: "Test2-Release"),
.release(name: "Test3-Release"),
.release(name: "Test4-Release"),
],
defaultSettings: .recommended
),
targets: [
.target(
name: "EventTracking",
destinations: [
.iPhone,
.macWithiPadDesign
],
product: .framework,
bundleId: "com.organizationName.EventTracking",
deploymentTargets: DeploymentTargets.iOS("15.0"),
sources: .paths(
["Sources/**/*.swift"]
),
dependencies: [
TargetDependency.package(
product: "AppsFlyerLib"
),
TargetDependency.project(
target: "Internal_Framework_With_Helpers",
path: .relativeToRoot("Projects/Internal_Framework_With_Helpers")
),
TargetDependency.project(
target: "Internal_Networking_Framework",
path: .relativeToRoot("Projects/Internal_Networking_Framework")
)
],
settings: .settings(
base: [
"DEVELOPMENT_ASSET_PATHS" : [""]
],
configurations: [],
defaultSettings: .recommended
)
),
.target(
name: "EventTrackingTests",
destinations: [
.iPhone,
.macWithiPadDesign
],
product: .unitTests,
bundleId: "com.organizationName.EventTrackingTests",
deploymentTargets: DeploymentTargets.iOS("15.0"),
sources: .paths(
["Tests/**/*.swift"]
),
dependencies: [
TargetDependency.project(
target: "EventTracking",
path: .relativeToRoot("Projects/Data/EventTracking")
),
TargetDependency.project(
target: "Internal_TestingSupport_Framework",
path: .relativeToRoot("Projects/Data/Internal_TestingSupport_Framework")
)
],
settings: .settings(
base: [
"DEVELOPMENT_ASSET_PATHS" : [""]
],
configurations: [],
defaultSettings: .recommended
)
)
],
additionalFiles: [],
resourceSynthesizers: [
.assets(),
.files(extensions: ["json"]),
]
)
Can any one explain me what i’m doing wrong and how I can make my EventTracking submodule testable with custom configurations Thanks
Potential solution
No response
macOS version
14.5
Tuist version
4.26.0
Xcode version
16.0
Yea, it looks like you get Debug (ENABLE_TESTABILITY = YES) and Release (ENABLE_TESTABILITY = NO) for free when you don’t specify any configs, however as soon as you specify a .release config, you only get that single config and you stop getting the Debug config implicitly. I’m kind of torn on this one. It’s a nice default to have, but seems to go against the ethos this project seems to side with of “be explicit”. It’s a nice default until half of it stops working in response to a change. But I get it and I’m not sure of a better way to handle the tradeoff.