Flutter on iOS: redefinition of module 'Firebase'
Solution 1
I've managed to resolve this issue by removing the firebase-ios-sdk dependency altogether. It appears that this is imported by the Flutter dependencies and adding it manually thus leads to a redefinition error.
I'd advise any people encountering this or similar errors to make sure that the integration steps they are following are meant for Flutter and not for iOS (only).
Solution 2
As Wouter Pol suggested, this error will most likely happen if you followed to many configuration guides and did some iOS-specific (non-Flutter) setup for Firebase.
I had to undo two changes:
1 - remove added code from AppDelegate.swift
Here is how it should look like - no import Firebase
and no FirebaseApp.configure()
2 - No package dependencies
I added the Firebase package before, but I don't need it when I already configured Flutter with appropriate packages.
Here is how Runner > Swift Packages
should look like:
Solution 3
If you use M1 try this
arch -x86_64 pod install
Wouter Pol
Updated on January 03, 2023Comments
-
Wouter Pol over 1 year
I've been trying to build my flutter app on iOS but
flutter run
is throwing the following error:/Users/<MyUser>/Desktop/projects/app/ios/Pods/Firebase/CoreOnly/Source s/module.modulemap:1:8: error: redefinition of module 'Firebase' module Firebase { ^ /Users/<MyUser>/Library/Developer/Xcode/DerivedData/Runner-dbkgurnsasbvieahfnk dontejqss/SourcePackages/checkouts/firebase-ios-sdk/CoreOnly/Sources/module. modulemap:1:8: note: previously defined here module Firebase {
I've imported the firebase-ios-sdk as per the instructions here. The imported modules are FirebaseCore, FirebaseAuth and FirebaseMessaging. I have not made any modifications to iOS-specific code (anything under /ios) apart from importing Firebase in the AppDelegate.swift file. The updated file now contains the following code:
import UIKit import Flutter import Firebase @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } }
After searching the error I've tried the following steps:
flutter clean
-
pod deintegrate
andpod install
- Cleaning DerivedData (both through XCode and manually)
- Remove and re-add firebase-ios-sdk
But to no avail.
-
Wouter Pol over 2 yearsUnfortunately I'm not using a M1-cpu. I've tried it nonetheless but, as one might have expected, it did nothing to resolve the issue.
-
Christian Leon about 2 yearsI don't even have this one lol
-
ΞΫΛL about 2 yearsThanks! That solved it for me! For others that might be looking for this, that is in Xcode → Projects → Runner → Package dependencies
-
ZXERSTON about 2 years@ΞΫΛL Hi! I can't seem to find package dependencies folder/file under my runner. Can you enlighten me on this matter?
-
ΞΫΛL about 2 yearsTry this guide: !removing dependencies