gpt4 book ai didi

ios - 添加 firebase_messaging 包后,Flutter 应用程序无法运行

转载 作者:行者123 更新时间:2023-12-03 16:31:53 27 4
gpt4 key购买 nike

这是来自 vscode 的日志

Launching lib/main.dart on iPhone 11 in debug mode...
Running pod install... 3.9s
Running Xcode build...
Xcode build done. 10.3s
Failed to build iOS app
Error output from Xcode build:

** BUILD FAILED **


Xcode's output:

/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:195:43: error: expected a type
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:302:53: error: nullability specifier 'nonnull' conflicts with
existing specifier 'nullable'
didReceiveRegistrationToken:(nonnull NSString *)fcmToken {
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:307:24: error: expected a type
didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage {
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:141:30: error: property 'shouldEstablishDirectChannel' not
found on object of type 'FIRMessaging *'
[FIRMessaging messaging].shouldEstablishDirectChannel = true;
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:160:21: warning: 'FIRInstanceID' is deprecated: FIRInstanceID
is deprecated, please use FIRInstallations for installation identifier handling and use FIRMessaging for FCM registration token handling. [-Wdeprecated-declarations]
[[FIRInstanceID instanceID]
^
In module 'FirebaseInstanceID' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Headers/Public/Firebase/Firebase.h:74:
/Users/abdurrohman/bsi/flutter_firebase/ios/Pods/FirebaseInstanceID/Firebase/InstanceID/Public/FIRInstanceID.h:190:1: note: 'FIRInstanceID' has been explicitly marked deprecated here
__deprecated_msg("FIRInstanceID is deprecated, please use FIRInstallations for installation "
^
In module 'UIKit' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation
.h:6:
In module 'Darwin' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFo
undation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro
'__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:161:33: warning: 'FIRInstanceIDResult' is deprecated:
FIRInstanceIDResult is deprecated, please use FIRInstallations for app instance identifier handling and use FIRMessaging for FCM registration token handling.
[-Wdeprecated-declarations]
instanceIDWithHandler:^(FIRInstanceIDResult *_Nullable instanceIDResult,
^
In module 'FirebaseInstanceID' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Headers/Public/Firebase/Firebase.h:74:
/Users/abdurrohman/bsi/flutter_firebase/ios/Pods/FirebaseInstanceID/Firebase/InstanceID/Public/FIRInstanceID.h:153:1: note: 'FIRInstanceIDResult' has been explicitly marked
deprecated here
__deprecated_msg("FIRInstanceIDResult is deprecated, please use FIRInstallations "
^
In module 'UIKit' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation
.h:6:
In module 'Darwin' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFo
undation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro
'__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:161:9: warning: 'instanceIDWithHandler:' is deprecated: Use
`Installations.installationID(completion:)` to get the app instance identifier instead. Use `Messaging.token(completion:)` to get FCM registration token instead.
[-Wdeprecated-declarations]
instanceIDWithHandler:^(FIRInstanceIDResult *_Nullable instanceIDResult,
^
In module 'FirebaseInstanceID' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Headers/Public/Firebase/Firebase.h:74:
/Users/abdurrohman/bsi/flutter_firebase/ios/Pods/FirebaseInstanceID/Firebase/InstanceID/Public/FIRInstanceID.h:215:5: note: 'instanceIDWithHandler:' has been explicitly marked
deprecated here
__deprecated_msg("Use `Installations.installationID(completion:)` to get the app instance "
^
In module 'UIKit' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation
.h:6:
In module 'Darwin' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFo
undation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro
'__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:171:21: warning: 'FIRInstanceID' is deprecated: FIRInstanceID
is deprecated, please use FIRInstallations for installation identifier handling and use FIRMessaging for FCM registration token handling. [-Wdeprecated-declarations]
[[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error) {
^
In module 'FirebaseInstanceID' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Headers/Public/Firebase/Firebase.h:74:
/Users/abdurrohman/bsi/flutter_firebase/ios/Pods/FirebaseInstanceID/Firebase/InstanceID/Public/FIRInstanceID.h:190:1: note: 'FIRInstanceID' has been explicitly marked deprecated here
__deprecated_msg("FIRInstanceID is deprecated, please use FIRInstallations for installation "
^
In module 'UIKit' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation
.h:6:
In module 'Darwin' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFo
undation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro
'__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:171:33: warning: 'deleteIDWithHandler:' is deprecated: Use
`Installations.delete(completion:)` instead. Also check `Messaging.deleteData(completion:)`if you want to delete FCM registration token. [-Wdeprecated-declarations]
[[FIRInstanceID instanceID] deleteIDWithHandler:^void(NSError *_Nullable error) {
^
In module 'FirebaseInstanceID' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Headers/Public/Firebase/Firebase.h:74:
/Users/abdurrohman/bsi/flutter_firebase/ios/Pods/FirebaseInstanceID/Firebase/InstanceID/Public/FIRInstanceID.h:321:33: note: 'deleteIDWithHandler:' has been explicitly marked
deprecated here
__deprecated_msg("Use `Installations.delete(completion:)` instead. "
^
In module 'UIKit' imported from /Users/abdurrohman/bsi/flutter_firebase/ios/Pods/Target Support Files/firebase_messaging/firebase_messaging-prefix.pch:2:
In module 'Foundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation
.h:6:
In module 'Darwin' imported from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFo
undation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/usr/include/sys/cdefs.h:200:48: note: expanded from macro
'__deprecated_msg'
#define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:196:52: error: property 'appData' not found on object of type
'__strong id'
[self didReceiveRemoteNotification:remoteMessage.appData];
^
/Users/abdurrohman/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:308:63: error: property 'appData' not found on object of type
'__strong id'
[_channel invokeMethod:@"onMessage" arguments:remoteMessage.appData];
^
5 warnings and 6 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target
'FirebaseFirestore' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target
'firebase_messaging' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 11.

最佳答案

#解决了
引用:

  • https://firebase.flutter.dev/docs/messaging/overview
  • https://github.com/MaikuB/flutter_local_notifications/issues/1004

  • 我在 iOS 设置上遇到了一些错误,这是我在 Podfile 上解决的设置。
    # Uncomment this line to define a global platform for your project
    platform :ios, '11.0'

    $FirebaseSDKVersion = '8.3.0'

    # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
    ENV['COCOAPODS_DISABLE_STATS'] = 'true'

    project 'Runner', {
    'Debug' => :debug,
    'Profile' => :release,
    'Release' => :release,
    }

    def flutter_root
    generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
    unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end

    File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
    end
    raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
    end

    require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

    flutter_ios_podfile_setup

    target 'Runner' do
    use_frameworks!
    use_modular_headers!
    flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end

    post_install do |installer|
    installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
    end
    end
    end
    当我检查 Android 时,我又遇到了一些新错误。一些问题来自 Activity 和 Application 的 Firebase 初始化。这是我在 Android 上解决的设置。
    MainApplication.kt
    package id.refactory.flutter_firebase

    import android.content.Context
    import androidx.multidex.MultiDex
    import com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin
    import io.flutter.app.FlutterApplication
    import io.flutter.plugin.common.PluginRegistry
    import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
    import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin
    import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService;

    class MainApplication : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
    super.onCreate()
    FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this)
    }

    override fun attachBaseContext(base: Context) {
    super.attachBaseContext(base)
    MultiDex.install(this)
    }

    override fun registerWith(registry: PluginRegistry?) {
    FlutterFirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebase.messaging.FirebaseMessagingPlugin"))
    FlutterLocalNotificationsPlugin.registerWith(registry?.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"))
    }
    }
    MainActivity.kt
    package id.refactory.flutter_firebase

    import android.os.Bundle
    import io.flutter.embedding.android.FlutterActivity
    import io.flutter.embedding.engine.FlutterEngine
    import io.flutter.plugins.GeneratedPluginRegistrant

    class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    }

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine)
    }
    }
    希望大家解决与此问题相关的问题。

    关于ios - 添加 firebase_messaging 包后,Flutter 应用程序无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65792345/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com