Swift cannot import a module that is installed in the project
No such module 'Firebase'Short answer
The compiler for this target cannot see the module, even though the code exists on disk. That means the build was started without the pod integration (a .xcodeproj opened instead of the .xcworkspace), the pod or package is attached to another target, or the Pods folder is out of date. Check which file Xcode has open and which target fails, then fix that link.
Fix it fast
1Find out which cause you have
Find out three things: which project file the build uses, whether the Pods folder exists, and which target shows the error. The line starting with the file path in the error tells you the target; the first command shows what is on disk.
ls -d ios/*.xcworkspace ios/*.xcodeproj ios/Pods ios/Podfile.lock grep -n "target\|inherit" ios/Podfile2Match what you see, then jump to its fix
- 1
The window title or the build log shows Runner.xcodeproj, a Pods folder exists, and every pod import failsThe project was opened as .xcodeproj, not .xcworkspaceFix - 2
The app target builds, but a test, extension or widget target reports No such module for a pod the app usesThe pod is declared for another target, or a test or extension target does not inherit itFix - 3
ios/Pods does not exist (fresh clone, flutter clean, or a deleted folder) or Podfile.lock lists a pod that Pods/ does not containThe Pods folder is missing or older than Podfile.lockFix - 4
The package shows under Package Dependencies, yet one target cannot import it; the target's Frameworks, Libraries, and Embedded Content list does not show the productA Swift package is in the project but its product is not linked to this targetFix
- 1
What does the error look like?
No such module 'Firebase'No such module 'Flutter'error: no such module 'SomePod' in a test, extension or widget target
Cause 1 of 4
The project was opened as .xcodeproj, not .xcworkspace
1Check
CocoaPods builds the pods in a second project and joins both in a workspace. Only the workspace knows about the pod targets and their module search paths. The CocoaPods troubleshooting guide tells you to open the .xcworkspace, not the .xcodeproj, when Xcode builds fail with pods.
ls ios/*.xcworkspace
ps aux | grep -i "[X]code.app" | head -12Fix
Close the project and open the workspace file. For Flutter, build from the terminal or open the workspace from the ios folder. With xcodebuild pass -workspace, not -project.
open ios/Runner.xcworkspace
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -sdk iphonesimulator build3Verify
The build log lists Pods targets and the import error is gone.
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -sdk iphonesimulator build 2>&1 | grep -c "No such module"Confirmed by guides.cocoapods.org
Cause 2 of 4
The pod is declared for another target, or a test or extension target does not inherit it
1Check
Each target block in the Podfile belongs to one Xcode target, and by default it inherits only what is declared above it. A new target that has no block gets no pods at all. A test target needs the app's pods on its search path, which the Podfile expresses with inherit! :search_paths. Compare the Podfile with the target list.
xcodebuild -project ios/Runner.xcodeproj -list
cat ios/Podfile2Fix
Add a target block for the failing target, listing the pods it imports, or for a test target nest it in the app's block with search-path inheritance. Then install again so CocoaPods rewrites the target's settings.
target 'Runner' do
pod 'SomePod'
target 'RunnerTests' do
inherit! :search_paths
end
end
# then
cd ios && pod install3Verify
pod install finishes without errors and the failing target now compiles.
cd ios && pod install
xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphonesimulator build 2>&1 | grep -c "No such module"Confirmed by guides.cocoapods.org
Cause 3 of 4
The Pods folder is missing or older than Podfile.lock
1Check
pod install creates the Pods project and records versions in Podfile.lock. If the folder is gone or was made from another Podfile, the module is not built. For a Flutter app, pub get also has to run first, because the plugin list comes from it.
ls ios/Pods | head -3
diff ios/Podfile.lock ios/Pods/Manifest.lock && echo same2Fix
Run pub get and then install the pods again. If a pod's version must change, use pod update with the pod's name; plain pod install keeps the versions in Podfile.lock.
flutter pub get
cd ios && pod install3Verify
Manifest.lock matches Podfile.lock and the module builds.
diff ios/Podfile.lock ios/Pods/Manifest.lock && echo same
flutter build ios --no-codesignConfirmed by guides.cocoapods.org
Cause 4 of 4
A Swift package is in the project but its product is not linked to this target
1Check
Adding a package asks which products go to which targets; a package alone is not linked anywhere. A product linked to the app target is not automatically available to a test or extension target. Look at the target's linked products in the project file.
grep -n "packageProductDependencies" ios/Runner.xcodeproj/project.pbxproj
xcodebuild -project ios/Runner.xcodeproj -list2Fix
Select the failing target, open General, and under Frameworks, Libraries, and Embedded Content press + and add the package product. Add it for each target that imports it.
# Xcode: target > General > Frameworks, Libraries, and Embedded Content > +
# then check the product is listed for that target
grep -n "productName" ios/Runner.xcodeproj/project.pbxproj3Verify
The product is listed for the failing target and the import resolves.
xcodebuild -project ios/Runner.xcodeproj -scheme Runner -sdk iphonesimulator build 2>&1 | grep -c "No such module"Confirmed by developer.apple.com
How do I stop it coming back?
- Open the workspace, never the project, in any CocoaPods project; keep a short note in the README.
- When you add an app extension or test target, add its target block to the Podfile in the same commit and run pod install.
- Commit Podfile.lock so every machine builds the same pods.
- After flutter clean, run flutter pub get and pod install before opening Xcode.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Dawlance AirA companion app for smart air conditioners, with IoT pairing across native and Flutter layers.
Related fixes
Mobile apps
Simulator build fails because a library was built for real iPhones
building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
The linker was building for the Simulator and met a library compiled only for physical iPhones.
4 causes, each with a fixMobile apps
Xcode says a script phase failed, but not which one or why
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
This line only reports that one Run Script build phase exited with an error.
4 causes, each with a fixMobile apps
CocoaPods refuses a Swift pod that depends on a pod without modules
... does not define modules.
CocoaPods builds Swift pods as static libraries only if every pod they import defines a module.
2 causes, each with a fixMobile apps
FirebaseMessaging.getAPNSToken() returns null on iOS
FirebaseMessaging.instance.getAPNSToken() returns null
getAPNSToken() gives null when iOS has not handed the app an APNs token yet or never will.
4 causes, each with a fixMobile apps
Xcode cannot find GoogleService-Info.plist for the Runner target
error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')
Xcode's project file lists GoogleService-Info.plist as an input, but nothing exists at the path it records.
3 causes, each with a fixMobile apps
Firebase phone sign-in on iOS stops with 'Please register custom URL scheme'
Please register custom URL scheme com.googleusercontent.apps.123456789-abc in the app's Info.plist file.
Phone sign-in on iOS can open a reCAPTCHA page, and Firebase needs a URL scheme in Info.plist to return to your app.
2 causes, each with a fix