I updated Xcode to version 14 last week and I wanted to get our app ready for working on Xcode 14. As it turns out, Xcode 14 gives me an error when trying to test our regular scheme which is working fine on Xcode 13.x.
I'm getting No Such Module 'ModuleX' even thought I am importing the module in the Package.swift file. It looks like this:
let package = Package(
name: "App",
defaultLocalization: "en",
platforms: [.iOS(.v13), .macOS(.v10_14)],
products: [
.library(name: "DesignSystem", targets: ["DesignSystem"]),
],
dependencies: [
.package(url: "git@ssh.blablabla/components-ios", from: "2.0.0")
],
targets: [
.target(
name: "DesignSystem",
dependencies: [
.product(name: "ModuleX", package: "components-ios")
]
)
]
)
I removed a ton of other packages here and renamed some modules because of the example. Other targets have DesignSystem as a dependency and that compiles just fine. I'm just getting very confused about what's going on.
A regular build and run on simulator compiles, but when I'm testing the scheme, he cannot seem to locate this specific Module. I'm using swift tools version 5.6.
Do you have any advice?
Thanks in advance.
If you create a project from scratch, everything will work as expected.
For this particular case, I’m using xcodegen, which appears to have broken some project settings after generating the project. If you open the Build Settings
of the unit-test target and look at the Bundle Loader
property, you will see $(TEST_HOST)
key, which leads to the problem described above.
To fix this problem, we need to update the Bundle Loader
setting inside the unit-test target settings. If you are using xcodegen
, just add this line to the test target settings as follows:
<AppName>Tests:
type: bundle.unit-test
platform: iOS
settings:
BUNDLE_LOADER: $(BUILT_PRODUCTS_DIR)/<AppName>.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/<AppName>
If you aren't using xcodegen
, open the project's settings and ensure that your Bundle Loader
setting looks like this:
$(BUILT_PRODUCTS_DIR)/<AppName>.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/<AppName>