Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Xcode cannot find the Firebase module inside a framework or library

ErrorNo such module 'Firebase'

Short answer

A target only sees the pods declared for it. If a library or framework target imports Firebase, the Podfile must list the pod inside that target, or the library's podspec must declare it as a dependency. Also open the .xcworkspace, not the .xcodeproj, and run pod install again.

  • Applies to CocoaPods, Xcode, Swift
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which target fails, and whether the Podfile names that target. Then confirm you opened the workspace.

    cat Podfile
    ls -d *.xcworkspace
  2. 2Match what you see, then jump to its fix

    1. 1The build fails on the first import, and the Pods project does not appear in Xcode's navigatorThe project was opened instead of the workspaceFix
    2. 2Firebase pods are declared only in the app target, and the import fails in the library targetThe library target is not listed in the PodfileFix
    3. 3The library has its own .podspec, and consumers get No such module 'Firebase'The library ships as a pod, but its podspec lacks the dependencyFix

What does the error look like?

  • No such module 'Firebase'

Cause 1 of 3

The project was opened instead of the workspace

1Check

Firebase's setup guide tells you to open the .xcworkspace file, not the .xcodeproj, after pod install.

ls -d *.xcworkspace *.xcodeproj

2Fix

Close the project and open the workspace.

open MyApp.xcworkspace

3Verify

The Pods project appears next to your project in the navigator, and the module is found on the next build.

xcodebuild -workspace MyApp.xcworkspace -scheme MyLibrary -destination 'generic/platform=iOS Simulator' build

Confirmed by firebase.google.com

Did this fix it?

Cause 2 of 3

The library target is not listed in the Podfile

1Check

Pods declared inside a target block apply only to that target. A framework target in the same workspace gets nothing from the app's block unless it is nested or shares an abstract target.

grep -n "target\|pod " Podfile

2Fix

Declare the pod in the library target's block, or share the pods with an abstract target.

use_frameworks!

abstract_target 'Shared' do
  pod 'FirebaseAuth'

  target 'MyApp'
  target 'MyLibrary'
end

3Verify

Reinstall the pods and rebuild the library scheme.

pod install

Confirmed by guides.cocoapods.org

Did this fix it?

Cause 3 of 3

The library ships as a pod, but its podspec lacks the dependency

1Check

A pod's dependencies are declared in its podspec. If the code imports Firebase but the podspec does not name the pod, the consumer's build does not link or find it.

grep -n "dependency" *.podspec

2Fix

Add the dependency with a version requirement. The docs recommend the optimistic operator so the pod stays compatible with others.

s.dependency 'FirebaseAuth', '~> 11.0'   # example version, use the one you build against

3Verify

Run pod install in a project that consumes the library and build it.

pod install

Confirmed by guides.cocoapods.org

Did this fix it?

How do I stop it coming back?

  • Open the .xcworkspace as the only way into the project, and delete the habit of opening the .xcodeproj.
  • Whenever you add a target, add it to the Podfile in the same commit.
  • Check the Firebase setup page for the linkage rule (static or dynamic) before changing use_frameworks!.

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:

Related fixes

Mobile apps

InstanceID token() no longer works in a Swift Firebase app

Instance ID calls fail to compile after upgrading Firebase to 8.0.0 or later

Firebase removed the Instance ID dependency from Messaging in 8.0.0, so InstanceID.instanceID() calls no longer belong in a current app.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.