Flutter iOS 构建失败,并在 url_launcher_ios 中显示“UIApplication 不符合协议‘Launcher’”错误

问题描述 投票:0回答:1

尝试在 iOS 模拟器上运行我的 Flutter 应用程序时遇到构建错误。该错误似乎与 url_launcher_ios 插件有关。

错误信息:

/Users/user/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.4/ios/Classes/Launcher.swift:20:1: error: type 'UIApplication' does not conform to protocol 'Launcher'
extension UIApplication: Launcher {}
^
UIKit.UIApplication:24:15: note: candidate has non-matching type '(URL, [UIApplication.OpenExternalURLOptionsKey : Any], (@MainActor @Sendable (Bool) -> Void)?) -> Void'
open func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: (@MainActor @Sendable (Bool) -> Void)? = nil)

我尝试过的: 更新了 Podfile 以使用 iOS 12.0:

platform :ios, '12.0'

清理并重新安装依赖项:

flutter clean
flutter pub get
cd ios
pod deintegrate
pod cache clean --all
pod install

pubspec.yaml 依赖项:

dependencies:
  flutter:
    sdk: flutter
  url_launcher: ^6.2.4

我的问题:* 我最近将模拟器更新到 18.1 iPhone 16 Plus,这些不同的错误开始弹出,之前的错误是:

suggests that the build process for your iOS app
in Xcode failed, and the main issue seems to be
that certain Flutter dependencies (e.g., sqflite)
are unable to locate Flutter.h

发现此错误的原因是什么以及如何修复它?

这是完整的错误

Writing result bundle at path:
    /var/folders/cd/yh1682_95jz__1z337mbc0dh0000gp/T/flutter_tools.KNaYLQ/flutter_ios_build_temp_dir1iOiMu/temporary_xcresult_bundle

/Users/User/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.4/ios/Classes/Launcher.swift:20:1: error: type 'UIApplication' does not conform to protocol 'Launcher'
extension UIApplication: Launcher {}
^
UIKit.UIApplication:24:15: note: candidate has non-matching type '(URL, [UIApplication.OpenExternalURLOptionsKey : Any], (@MainActor @Sendable (Bool) -> Void)?) -> Void'
    open func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
              ^
/Users/User/.pub-cache/hosted/pub.dev/url_launcher_ios-6.2.4/ios/Classes/Launcher.swift:20:1: note: add stubs for conformance
extension UIApplication: Launcher {}
^

/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'PromisesObjC' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'OrderedSet' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'path_provider_foundation-path_provider_foundation_privacy' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'nanopb' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'image_picker_ios-image_picker_ios_privacy' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'shared_preferences_foundation-shared_preferences_foundation_privacy' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'url_launcher_ios-url_launcher_ios_privacy' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'google_mobile_ads-google_mobile_ads' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'url_launcher_ios' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'shared_preferences_foundation' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'path_provider_foundation' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'GoogleUtilities' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'flutter_inappwebview' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'GoogleAppMeasurement' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'image_picker_ios' from project 'Pods')

note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')

/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'Flutter' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'Google-Mobile-Ads-SDK' from project 'Pods')
/Users/User/StudioProjects/Project/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.1.99. (in target 'GoogleUserMessagingPlatform' from project 'Pods')

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

如果有任何不清楚或需要更多代码片段,请告诉我

这是唯一不工作的项目,其他项目模拟器正在工作

ios flutter xcode url-launcher
1个回答
0
投票

pubspec.yml 中的依赖项更新为兼容版本

dependencies:

颤动: sdk:颤动 url_启动器:^6.1.7 url_launcher_ios: ^6.1.7

奔跑

flutter pub get

然后清理并构建缓存

flutter clean
flutter pub get
cd ios
pod install
flutter run
© www.soinside.com 2019 - 2024. All rights reserved.