Skip to content
Latchkey

Swift "No such module" in Xcode CI Builds

The Swift compiler could not resolve an import. The module exists in your dependency list but was not built or made visible to this build - usually because the wrong container was built or pods/packages were not resolved.

What this error means

Compilation fails on an import Foo line with "no such module 'Foo'". It is common in CI when the project (.xcodeproj) is built instead of the workspace, so CocoaPods/SPM modules are not on the search path.

Swift compiler
/Users/runner/App/AppDelegate.swift:3:8: error: no such module 'Alamofire'
import Alamofire
       ^

Diagnose it: SDK, signing, or simulator?

Mobile CI failures cluster into three: a missing or mismatched SDK component, a code-signing identity that does not exist on the runner, or a simulator or emulator that never became ready.

Terminal
# Android
sdkmanager --list_installed 2>/dev/null | head
echo "ANDROID_HOME=$ANDROID_HOME"
adb devices

# iOS
xcodebuild -version && xcrun simctl list devices available | head
security find-identity -v -p codesigning

Common causes

Building the project instead of the workspace

CocoaPods integrates through the .xcworkspace. Building -project App.xcodeproj skips the Pods project, so pod modules are missing.

Dependencies not resolved before building

If pod install or SPM resolution did not run (or its cache was stale), the module was never built and cannot be imported.

How to fix it

Build the workspace, not the project

Terminal
xcodebuild -workspace App.xcworkspace -scheme App build
# not: xcodebuild -project App.xcodeproj ...

Resolve dependencies before building

Install pods and/or resolve Swift packages first so the modules exist.

Terminal
pod install
xcodebuild -resolvePackageDependencies -workspace App.xcworkspace -scheme App

Check the module name and target membership

  1. Confirm the import name matches the framework’s product/module name.
  2. Ensure the dependency is added to the target that imports it.
  3. Clean derived data if a stale build is masking a resolved module.

How to prevent it

  • Always reference the .xcworkspace when CocoaPods is used.
  • Run pod install / -resolvePackageDependencies as an explicit CI step.
  • Commit Podfile.lock / Package.resolved so versions are reproducible.

Frequently asked questions

What causes Swift "No such module" in Xcode CI builds?
There are 2 common causes: building the project instead of the workspace and dependencies not resolved before building. CocoaPods integrates through the .xcworkspace.
How do I fix Swift "No such module" in Xcode CI builds?
There are 3 fixes depending on which cause you have: build the workspace, not the project, resolve dependencies before building, and check the module name and target membership. Work through them in order, since the first is the most common.
What does Swift "No such module" in Xcode CI builds actually mean?
Compilation fails on an import Foo line with "no such module 'Foo'".
How do I stop Swift "No such module" in Xcode CI builds happening again?
Always reference the .xcworkspace when CocoaPods is used. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card