2

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:

  1. the only package I've added to the project is Firebase (9.6.0) and as I mentioned, it was added via SPM
  2. no Cocoapods or Carthage was ever used in this project, so I'm using just the xcodeproj file.
  3. Enable testability is set to true for Debug configuration in both targets (the main and the test)
  4. the scheme is set up to launch the tests with Debug conf
  5. the get the same results when I run the tests in a host app or not
  6. I've also tried to remove the test target and add it again, but no change
  7. Xcode 14.1 and M1 machine
  • Did you ever get this sorted? Facing the same issue here. – mylogon Mar 02 '23 at 10:40
  • unfortunately, no. I was about to have a breakdown so now I'm just ignoring the project :)) – thelioncubofcintra Mar 03 '23 at 12:20
  • I seemed to have fixed it/ it fixed itself so I'm happy but upset with the whole thing. Literally 2 days down the toilet for no apparent reason. I think with this I ended up removing all files from the project (removing reference) and then adding them all back in again. I think it stemmed from a bad merge conflict resolution but I'm not 100% sure as I had another stupid error that fixed itself around the same time. – mylogon Mar 03 '23 at 16:06

1 Answers1

-1

I was able to resolve this issue on my unit test target by

  • creating a new project named MyApp
  • Navigate to the Unit Test target's build settings
  • search for TEST_HOST
  • You should see both Linking -> Bundle Loader and Testing -> Test Host sections

In your actual project, do the following:

  • set all the bundle loader Build Configurations (e.g., Debug / Release, etc) to $(TEST_HOST)
  • Set all the Test Host Build Configurations to $(BUILT_PRODUCTS_DIR)/MyApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MyApp, replacing MyApp with your corresponding .app name

Test host settings after the change

Campbell_Souped
  • 871
  • 10
  • 22