Swift Package libraries always results in "No such module" when imported

Hello community :wave:

In a Xcode 15.1 in a project I am adding a SPM library.
Project >> Package Dependencies >> + >> added succesfully (without any errors)

Then I make sure that the package is added in:
Target >> Frameworks, Libraries and embedded content

Everything is going well until I am trying to import that SPM. It says "No such module found".

Here is what I have tried so far:

  • I tried to do this in a fresh project and it worked well.
  • I tried creating a new app target in same project and still did not work.
  • I tried comparing the buildSettings but I did not find something worth mentioning.
  • I tried changing the configuration from main to use Debug prefix.
  • I tried with other SPM but with no success.
  • I tried deleting DerivedData and clean build many times.

Is there something that makes SPM not linking the library? I am also attaching the results of the xcodebuild -showBuildSettings command if you can find something.

Can someone shed a light on this one? Thank you in advance.

[edit] - I made a test project and it worked, but I see now that you have already tried that...

Thank you for the reply @Diggory, yes doing it in another project works well as you did. The problem seems to be in this specific project and I do not know how I can find the root cause.

Any ideas or debugging tips would be highly appreciated :slight_smile:

Is the Library in the 'Link Binary With Libraries' Build Phase?

@Diggory Yes it's also in this list. It's my first time this is happening to me.

For future readers :point_down:
After hours of investigation I think I finally found the culprit behind it.
It's the CONFIGURATION_BUILD_DIR that was overriden in this project.
Changing the configuration so that it matches the CONFIGURATION_BUILD_DIR did the trick.

Seems like that SPM is using the configuration name as a CONFIGURATION_BUILD_DIR .
But the app target was making the StagingDebug-iphoneSimulator which was different.



After renaming, it was working fine :tada:
At least now I know what I need to fix.

1 Like