Tom*_*ard 3 xcode notifications dart flutter awesome-notifications
当运行我的 iOS 版 Flutter 应用程序时,出现以下错误:
\nXcode build done. 86.8s\nFailed to build iOS app\nCould not build the precompiled application for the device.\nSwift Compiler Error (Xcode): No such module \'shared_preferences_ios\'\n/Users/tomasward/Desktop/fredi_new/ios/Runner/AppDelegate.swift:3:7\nRun Code Online (Sandbox Code Playgroud)\n这是从这段代码派生出来的AppDelegate.swift:
import UIKit\nimport Flutter\nimport awesome_notifications\nimport shared_preferences_ios //error here\n\n@UIApplicationMain\n@objc class AppDelegate: FlutterAppDelegate {\n override func application(\n _ application: UIApplication,\n didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?\n ) -> Bool {\n GeneratedPluginRegistrant.register(with: self)\n \n if #available(iOS 10.0, *) {\n UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate\n }\n \n application.registerForRemoteNotifications()\n \n\n SwiftAwesomeNotificationsPlugin.setPluginRegistrantCallback { registry in\n SwiftAwesomeNotificationsPlugin.register(\n with: registry.registrar(forPlugin: "io.flutter.plugins.awesomenotifications.AwesomeNotificationsPlugin")!)\n FLTSharedPreferencesPlugin.register(\n with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")!)\n }\n return super.application(application, didFinishLaunchingWithOptions: launchOptions)\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n此代码是awesome_notificationsios 插件设置的样板。看这里
flutter create .pod install一百万次,删除podfile等似乎没有一个解决方案是一致的。我正在寻找从事Flutter项目工作的人的通用解决方案,而不是本机 ios 项目。
awesome_notifications如果与我一起工作的人能给我一些见解,那就太好了
对于最新/当前版本,请执行以下操作
shared_preferences_ios用。。。来代替shared_preferences_foundation
与FLTSharedPreferencesPluginSharedPreferencesPlugin
因为这些是 flutter 内部最新的原生绑定,请参阅 PR。
AppDelegate.swift包含新更新解决方案的内容
import UIKit
import Flutter
import awesome_notifications
import shared_preferences_foundation //replace this here
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
application.registerForRemoteNotifications()
SwiftAwesomeNotificationsPlugin.setPluginRegistrantCallback { registry in
SwiftAwesomeNotificationsPlugin.register(
with: registry.registrar(forPlugin: "io.flutter.plugins.awesomenotifications.AwesomeNotificationsPlugin")!)
SharedPreferencesPlugin.register( // replace here
with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")!)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Run Code Online (Sandbox Code Playgroud)