在 iOS 中不推荐使用 Flutter 依赖项

Posted

技术标签:

【中文标题】在 iOS 中不推荐使用 Flutter 依赖项【英文标题】:Flutter dependencies are deprecated in iOS 【发布时间】:2021-05-29 15:29:19 【问题描述】:

我知道许多 Flutter 开发人员在他们的应用程序中使用了许多不同的包。现在,我正在尝试在 ios 中构建我的应用程序的最终版本,但这让我很头疼。我正在使用诸如 image_picker、flutter_local_notifications、flutter_inappwebview、firebase_messaging 等软件包。由于 Firebase 库的兼容性问题,我需要将 min. iOS 10.0。

这些是一些库的版本,在构建到 iOS on Simulator 时会出错。

image_picker: ^0.6.7+22
flutter_local_notifications: ^4.0.1
flutter_inappwebview: ^4.0.0+4

# Only Firebase_messaging gives errors between Firebase libraries but 
# I would like to show you the versions of all of them
firebase_admob: ^0.11.0+1
firebase_messaging:
firebase_core: ^0.7.0
firebase_auth: ^0.20.0+1
cloud_firestore: ^0.16.0

与 firebase_messaging 相关的一小部分警告


    In module 'UIKit' imported from /Users/zahidtekbas/Documents/GitHub/projectxyz-Flutter-App/projectxyz/ios/Pods/Target Support
    Files/firebase_messaging/firebase_messaging-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Li
    brary/Frameworks/UIKit.framework/Headers/UIUserNotificationSettings.h:17:32: note: 'UIUserNotificationType' has been
    explicitly marked deprecated here
    typedef NS_OPTIONS(NSUInteger, UIUserNotificationType) 
                                   ^
    /Users/zahidtekbas/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin
    .m:294:70: warning: 'UIUserNotificationTypeBadge' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications
    Framework's UNAuthorizationOptions [-Wdeprecated-declarations]
        @"badge" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeBadge],
                                                                         ^
    In module 'UIKit' imported from /Users/zahidtekbas/Documents/GitHub/projectxyz-Flutter-App/projectxyz/ios/Pods/Target Support
    Files/firebase_messaging/firebase_messaging-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Li
    brary/Frameworks/UIKit.framework/Headers/UIUserNotificationSettings.h:17:32: note: 'UIUserNotificationType' has been
    explicitly marked deprecated here
    typedef NS_OPTIONS(NSUInteger, UIUserNotificationType) 
                                   ^
    /Users/zahidtekbas/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin
    .m:295:70: warning: 'UIUserNotificationTypeAlert' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications
    Framework's UNAuthorizationOptions [-Wdeprecated-declarations]
        @"alert" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeAlert],

还有这些不推荐使用的方法,警告输出中不推荐使用的 UI 元素错误。 当我以分钟为目标时。 iOS 9.0,这次GoogleMobilAds、FirebaseInstanceID、flutter_inappwebview-4.0.0+4等报错。

因此,无论我的目标是什么平台,在为 iOS 构建时我都无法避免错误和警告。知道如何解决由于弃用的东西而导致的长段错误消息吗?

编辑:我正在添加颤振医生 -v 的输出


[✓] Flutter (Channel beta, 1.26.0-17.8.pre, on macOS 11.2 20D64 darwin-x64, locale en-TR)
    • Flutter version 1.26.0-17.8.pre at /Users/zahidtekbas/flutter
    • Framework revision 044f2cf560 (3 days ago), 2021-02-24 13:02:05 -0800
    • Engine revision 042c82b02c
    • Dart version 2.12.0 (build 2.12.0-259.16.beta)

[✓] android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/zahidtekbas/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 53.0.5
    • Dart plugin version 203.6912

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (2 available)
    • iPhone 12 Pro Max (mobile) • 943E0837-6EB7-45F6-B9F0-EC00160B2CDE • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 88.0.4324.192

构建输出结束:


    4 warnings generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team
    ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')

【问题讨论】:

您通过更改代码而不是目标版本来修复弃用警告。或者您忽略它们(毕竟它们是警告)并在下次升级时处理技术债务。 @tehhowch 这不是忽略。我认为它阻止我在 iOS 中构建应用程序。有没有其他建议的可能性?你认为这是因为 Xcode 中的新构建系统吗? 【参考方案1】:

升级到新的 Flutter 版本解决了我的问题。如果有人看到这一点,请考虑升级您的依赖项和 Flutter。

【讨论】:

我在 Flutter 2.5.3 (codemagic) 中仍然收到那些“在 iOS 10.0 中首次弃用”的警告。【参考方案2】:

我遇到了同样的问题,即使我将 minimumOSVersion 设置为 11.0 ,并且 IPHONEOS_DEPLOYMENT_TARGET 设置为 11.0 ,仍然显示不推荐使用的错误,可能是 Xcode 的问题,顺便说一句,我使用 Xcode 12.4 和 12.2 仍然错误

【讨论】:

以上是关于在 iOS 中不推荐使用 Flutter 依赖项的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 平台特定依赖项

Flutter Web:使用 HtmlElementView、IFrameElement、registerViewFactory 实现的解决方案在 ios 中不起作用

在 Spring Boot 1.4 中不推荐使用 FilterRegistrationBean。*

无法使用 PathProvider 依赖项构建颤振项目

为啥在 makefile 中不生成依赖项?

Flutter 背景 iOS 通知在 XCode 或 TestFlight 中不起作用