'How can I use the existing firebase-ios-sdk dependency in my native swift code?
I am working on a Flutter app that uses the FlutterFire firebase_messaging package.
I need to add delivery reports to my app, but the FlutterFire library does not support this.
So I must implement this native swift code.
But for this code to compile I must add the firebase-ios-sdk package to my 'Runner' project.
When building I now get the error...
Error (Xcode): redefinition of module 'Firebase'
Because both my Runner project and the FlutterFire dependency are both including the firebase-ios-sdk.
How can I import FirebaseMessaging in native swift code, while using the firebase-ios-sdk dependency that FlutterFire already imports?
If I try to add a library dependency from the existing flutter dependency (I go to General > Library Dependency > select "Pods > firebase_messaging"), the swift code is not able to resolve the 'import FirebaseMessaging' statement.
Solution 1:[1]
this works for me:
add your firebase package to pubspec.yaml
such as :
firebase_messaging: ^11.2.14
after that if you want to add "this native swift code" implementation you must just import below to AppDelegate file:
import Firebase
import FirebaseMessaging
and
Messaging.serviceExtension().exportDeliveryMetricsToBigQuery(withMessageInfo:request.content.userInfo)
instead of
Messaging.extensionHelper()
.exportDeliveryMetricsToBigQuery(withMessageInfo:request.content.userInfo)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


