I'm struggling with the SPM modules in the unit test target. Simply adding @testable import MyApp
and then running UTs ends up with an error saying that an SPM module has not been found.
To be more explicit, those are the error lines:
/MyApp-cxdzdpxkuamerffyiosojkxpvujl/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyAppTests.build/Objects-normal/arm64/MyAppTests.swiftdoc: No such file or directory
/MyApp-cxdzdpxkuamerffyiosojkxpvujl/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyAppTests.build/Objects-normal/arm64/MyAppTests.abi.json: No such file or directory
/MyApp-cxdzdpxkuamerffyiosojkxpvujl/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyAppTests.build/Objects-normal/arm64/MyAppTests.swiftmodule: No such file or directory
/MyApp-cxdzdpxkuamerffyiosojkxpvujl/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyAppTests.build/Objects-normal/arm64/MyAppTests.swiftsourceinfo: No such file or directory
I've checked the folder and those files aren't indeed there.
What I've tried and more details:
- the only package I've added to the project is Firebase (9.6.0) and as I mentioned, it was added via SPM
- no Cocoapods or Carthage was ever used in this project, so I'm using just the
xcodeproj
file. - Enable testability is set to true for Debug configuration in both targets (the main and the test)
- the scheme is set up to launch the tests with Debug conf
- the get the same results when I run the tests in a host app or not
- I've also tried to remove the test target and add it again, but no change
- Xcode 14.1 and M1 machine
I was able to resolve this issue on my unit test target by
TEST_HOST
In your actual project, do the following:
$(TEST_HOST)
$(BUILT_PRODUCTS_DIR)/MyApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MyApp
, replacingMyApp
with your corresponding .app name