Why do I get 'No such module' after adding a Swift package?

When you encounter the "No such module" error after adding a Swift package, it typically indicates that your project is unable to locate the module that was intended to be imported. This can happen for several reasons, including incorrect package configuration, issues with Xcode settings, or missing dependencies. Here are some steps to troubleshoot and resolve the issue:

  1. Ensure that the package is added correctly in your Xcode project under File > Swift Packages > Add Package Dependency.
  2. Check the package version specified in the project settings, ensuring it's compatible with your project requirements.
  3. Confirm that the target you are working on has the package listed in its "Frameworks, Libraries, and Embedded Content".
  4. If the package has dependencies, make sure they are also added and resolved correctly.
  5. Clean the build folder by selecting Product > Clean Build Folder to clear any cached data.
  6. Restart Xcode, as sometimes the IDE needs to refresh its settings.

By following these steps, you should be able to resolve the 'No such module' error and successfully use the Swift package in your project.


Swift No such module Swift package Xcode module import error troubleshooting