使用 Firebase In App Messaging 插件时 Flutter 无法编译项目

Posted

技术标签:

【中文标题】使用 Firebase In App Messaging 插件时 Flutter 无法编译项目【英文标题】:Flutter Cannot complie project when using Firebase In App Messaging plugin 【发布时间】:2020-06-30 22:31:34 【问题描述】:

我在 android 上成功实现了该插件,但是当我尝试在 ios 上启动该应用时,我收到一条错误消息。当我禁用插件并在 ios 上重新安装应用程序时,一切正常。 这是我的控制台日志:

Launching lib/main.dart on iPhone 5s in debug mode...
Running pod install...
Warning: Podfile is out of date
  This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes.
  If you have local Podfile edits you would like to keep, see https://github.com/flutter/flutter/issues/24641 for instructions.
To regenerate the Podfile, run:
  rm ios/Podfile

Running Xcode build...
Xcode build done.                                           41,0s
Could not build the application for the simulator.
Error launching application on iPhone 5s.
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    While building module 'FirebaseInAppMessaging' imported from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/FirebaseInAppMessagingDisplay/Firebase/InAppMessagingDisplay/FIDBaseRenderingViewController.h:19:
    In file included from <module-includes>:1:
    In file included from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/Target Support Files/FirebaseInAppMessaging/FirebaseInAppMessaging-umbrella.h:13:
    /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/FirebaseInAppMessaging/FirebaseInAppMessaging/Sources/Public/FirebaseInAppMessaging.h:21:2: warning: The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework). [-W#warnings]
    #warning The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework).
     ^
    1 warning generated.
    1 warning generated.
    1 warning generated.
    1 warning generated.
    While building module 'FirebaseInAppMessaging' imported from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/Headers/Public/Firebase/Firebase.h:53:
    In file included from <module-includes>:1:
    In file included from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/Target Support Files/FirebaseInAppMessaging/FirebaseInAppMessaging-umbrella.h:13:
    /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/FirebaseInAppMessaging/FirebaseInAppMessaging/Sources/Public/FirebaseInAppMessaging.h:21:2: warning: The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework). [-W#warnings]
    #warning The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework).
     ^
    1 warning generated.
    1 warning generated.
    While building module 'FirebaseInAppMessaging' imported from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/Headers/Public/Firebase/Firebase.h:53:
    In file included from <module-includes>:1:
    In file included from /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/Target Support Files/FirebaseInAppMessaging/FirebaseInAppMessaging-umbrella.h:13:
    /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/ios/Pods/FirebaseInAppMessaging/FirebaseInAppMessaging/Sources/Public/FirebaseInAppMessaging.h:21:2: warning: The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework). [-W#warnings]
    #warning The FirebaseInAppMessagingDisplay subspec is deprecated. Please remove FirebaseInAppMessagingDisplay from your Podfile (or delete the framework).
     ^
    1 warning generated.
    1 warning generated.
    duplicate symbol '_OBJC_CLASS_$_FIRIAMDefaultDisplayImpl' in:
        /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/build/ios/Debug-iphonesimulator/FirebaseInAppMessaging/FirebaseInAppMessaging.framework/FirebaseInAppMessaging(FIRIAMDefaultDisplayImpl.o)
        /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/build/ios/Debug-iphonesimulator/FirebaseInAppMessagingDisplay/FirebaseInAppMessagingDisplay.framework/FirebaseInAppMessagingDisplay(FIRIAMDefaultDisplayImpl.o)
    duplicate symbol '_OBJC_METACLASS_$_FIRIAMDefaultDisplayImpl' in:
        /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/build/ios/Debug-iphonesimulator/FirebaseInAppMessaging/FirebaseInAppMessaging.framework/FirebaseInAppMessaging(FIRIAMDefaultDisplayImpl.o)
        /Users/manolo/Developer/flutterprojects/fitness_recipes_clean/build/ios/Debug-iphonesimulator/FirebaseInAppMessagingDisplay/FirebaseInAppMessagingDisplay.framework/FirebaseInAppMessagingDisplay(FIRIAMDefaultDisplayImpl.o)
    ld: 2 duplicate symbols for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Planning build
    note: Constructing build description

有人遇到过同样的问题并且能够解决吗?

【问题讨论】:

这里有同样的问题 @nemoryoliver 我终于修好了。您可以在下面阅读我的答案 【参考方案1】:

我修好了!

    评论 firebase_in_app_messaging 即(#firebase_in_app_messaging:^0.1.1+3) 在 pubspec.yaml 中

    运行flutter packages get

    删除 ios 文件夹内的 Podfile.lock 打开你的终端 cd 到项目 ios 文件夹 输入Vim Podfile 按“i”进入插入模式 将这些添加到底部的行中:pod 'Firebase', '6.15.0'pod 'FirebaseInAppMessaging', '0.16.0' 按键盘上的“esc”保存 输入pod install 输入pod update Firebase/Core 在 pubspec.yaml 中添加取消注释 firebase_in_app_messaging 运行flutter packages get

【讨论】:

【参考方案2】:

您可以尝试以下方法:

干净利落。

rm ios/Podfile

rm ios/Podfile.lock

吊舱更新

吊舱安装

这可以完成工作。

【讨论】:

嘿,您应该尝试更具体地回答您的问题,您只是写了一些在这种情况下没有用的通用内容。只是一个建议。干杯 OP 有一个关于 Podfile 已过期的警告。一旦我遇到类似的问题,这对我有用。怎么能更具体呢?我应该写一些文章还是什么?

以上是关于使用 Firebase In App Messaging 插件时 Flutter 无法编译项目的主要内容,如果未能解决你的问题,请参考以下文章

如何停止在 iOS 上跟踪 in_app_purchase Firebase 事件?

在Ionic中实施Firebase In-App Messaging

Firebase SSO Auth 在 Facebook In App Browser 中不起作用

iOS 14.5 App Tracking Transparency for firebase log in react-native app

TypeError:无法使用“in”运算符在未定义中搜索“$__firebase”

从 Firebase(或其他平台)向特定终端发送 IOS 通知