Software⏱️ 3 min read📅 2026-06-04

How to Fix: Getting 'no such module' error when importing a Swift Package Manager dependency

Fix 'no such module' error when importing Swift Package Manager dependency with CocoaPods.

Quick Answer: Update CocoaPods and re-run `pod install` to resolve the issue.

The 'no such module' error occurs when trying to import a Swift Package Manager dependency in an Xcode project that uses CocoaPods. This issue affects developers who have migrated their projects from CocoaPods to Swift Package Manager, resulting in compilation failures.

This frustrating error can be caused by a variety of factors, including incorrect configuration, missing dependencies, or conflicts between frameworks and libraries.

⚠️ Common Causes

  • The primary reason for this issue is that Swift Package Manager requires a specific configuration to use static libraries. When using CocoaPods, the dependency is added as a framework, which causes the 'no such module' error.
  • Another possible cause is that the dependency's build settings are not configured correctly. This can be due to missing or incorrect values for the 'Library Search Paths', 'Header Search Paths', and 'Framework Search Paths'.

🚀 How to Resolve This Issue

Configuring Swift Package Manager for Static Libraries

  1. Step 1: Step 1: Create a new Swift package in your Xcode project. To do this, go to Product > Scheme > Edit Scheme... and add the 'Package' target under the 'Targets' section.
  2. Step 2: Step 2: In the 'Build Settings' tab of your package's target, set the 'Library Search Paths' to point to the correct location for the static library.
  3. Step 3: Step 3: Set the 'Header Search Paths' to point to the correct location for the header files.
  4. Step 4: Step 4: Remove any frameworks or libraries that are not necessary for your project, as they can cause conflicts with the static library.

Configuring CocoaPods to Use Static Libraries

  1. Step 1: Step 1: Update your Podfile to use the 'static' keyword when importing the dependency. For example, add `pod 'YourDependency', :static` instead of `pod 'YourDependency'.`
  2. Step 2: Step 2: Run `pod install` in your terminal to update the project's dependencies.

🎯 Final Words

By following these steps, you should be able to resolve the 'no such module' error and successfully use Swift Package Manager with static libraries. Remember to carefully configure your build settings and remove any unnecessary frameworks or libraries to avoid conflicts.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions