2

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: "[email protected]/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.

1 Answer 1

0

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.

enter image description here

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:

enter image description here

$(BUILT_PRODUCTS_DIR)/<AppName>.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/<AppName>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.