'No such module' when I use CocoaPods
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The Xcode error No such module after adding a pod usually means the dependency was not integrated into the build configuration Xcode is actually using. The fix is usually not in Swift source code, but in the workspace, target settings, Pod installation, or stale build artifacts.
Start with the Correct Project File
After running CocoaPods, you should normally open the generated .xcworkspace file, not the original .xcodeproj file. The workspace includes both your app target and the Pods project, which is how Xcode finds the installed modules during compilation.
Typical setup commands are:
If you keep opening .xcodeproj, the pod may exist on disk while the compiler still reports No such module because the Pods project is not loaded.
Confirm the Pod Is Installed for the Right Target
A common configuration mistake is putting the pod in the wrong target block inside the Podfile.
If the pod belongs to MyAppTests or another target but your main app imports it, the module will not be available where you expect it. After editing the Podfile, rerun:
Then rebuild the workspace.
Clean Derived Data and Rebuild
Xcode sometimes keeps stale build information even after pods are installed correctly. A clean rebuild is often enough to clear the error.
Then in Xcode:
- close the workspace
- reopen the
.xcworkspace - build again
This is especially useful after changing Swift versions, renaming targets, or switching branches.
Check Framework Integration Settings
If the workspace is correct and the pod is installed, look at how the target links frameworks. Problems here are often caused by manual project edits, old Podfiles, or target inheritance issues.
Useful checks include:
- the pod is listed in the correct target section of
Podfile.lock - the build uses the generated Pods configuration files
- '
$(inherited)appears in relevant build settings' - the app target and pod support the same platform and architecture
If the pod uses frameworks, use_frameworks! or the appropriate linkage setting may be required depending on the dependency.
Example Import
A correct integration should let you import the module directly in Swift.
If this import fails even though CocoaPods reports success, the issue is almost always in project integration rather than the Swift file itself.
When Architecture or Version Mismatch Is the Real Problem
Some pods do not support every Xcode version, Swift version, or Apple platform combination. The error can surface as No such module even though the deeper cause is an unsupported build target.
That is why checking the pod's README, supported iOS version, and recent release notes matters. On Apple Silicon machines, simulator architecture settings can also expose integration issues that did not appear on older Intel setups.
Common Pitfalls
- Opening
.xcodeprojinstead of.xcworkspaceis the most common CocoaPods integration mistake. Always build from the workspace afterpod install. - Adding the pod to the wrong target in the
Podfileleaves the intended app target without the dependency. Verify the target block carefully. - Changing the
Podfilewithout rerunningpod installleaves the workspace out of sync with the declared dependencies. Reinstall after every meaningful Podfile edit. - Ignoring stale Derived Data can make a fixed configuration still look broken. Clean the build artifacts when troubleshooting persists.
- Assuming every pod supports your current Xcode, Swift, and platform combination can hide a version-compatibility problem. Check the pod documentation when integration looks correct but compilation still fails.
Summary
- '
No such modulewith CocoaPods is usually an integration problem, not a Swift syntax problem.' - Open the
.xcworkspace, not the.xcodeproj. - Make sure the pod is installed under the correct target and rerun
pod installafter changes. - Clean Derived Data when Xcode keeps stale module state.
- Confirm the pod actually supports your toolchain and target platform.

