Flutter打包IOS15报错@available(iOS 13.0, macOS 10.15, *)

问题描述

运行 flutter build ios报错

   --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:iOS Simulator, id:84A0D7F0-FFAF-46D3-AC09-07D7107107C9, OS:15.5, name:iPhone 8 }
    { platform:iOS Simulator, id:A7666218-A765-4EC8-B4E9-9C0E290544B5, OS:15.5, name:iPhone 8 Plus }
    { platform:iOS Simulator, id:60DB0288-40FC-4B2D-A7BA-C342B566E404, OS:15.5, name:iPhone 11 }
    { platform:iOS Simulator, id:8C6C7AAF-294A-4455-AC04-BD732A4985E3, OS:15.5, name:iPhone 11 Pro }
    { platform:iOS Simulator, id:A5661A05-E201-4AB5-BE45-4880B7DA1863, OS:15.5, name:iPhone 11 Pro Max }
    { platform:iOS Simulator, id:4CCF6F2A-1CC6-4226-9D48-1AF1235E30BF, OS:15.5, name:iPhone 12 }
    { platform:iOS Simulator, id:6385DEC3-9DB7-489E-A0C8-2120BADF399F, OS:15.5, name:iPhone 12 Pro }
    { platform:iOS Simulator, id:EAF7751B-BDF7-4FCF-9DAF-A437E7717BA4, OS:15.5, name:iPhone 12 Pro Max }
    { platform:iOS Simulator, id:4415955E-C05D-456E-923B-D772C0A3B70B, OS:15.5, name:iPhone 12 mini }
    { platform:iOS Simulator, id:886E5FA1-8F24-47E3-8E10-BF951AC5D786, OS:15.5, name:iPhone 13 }
    { platform:iOS Simulator, id:FD19CFDC-EC31-4E27-BDBD-BB5BAFC6D96F, OS:15.5, name:iPhone 13 Pro }
    { platform:iOS Simulator, id:C880316B-A982-4055-8C46-FE4258842230, OS:15.5, name:iPhone 13 Pro Max }
    { platform:iOS Simulator, id:A219287E-A900-4ED0-87E9-53DEA96417BF, OS:15.5, name:iPhone 13 mini }
    { platform:iOS Simulator, id:48564DEB-1107-4EE5-A325-E3902502F44C, OS:15.5, name:iPhone SE (3rd generation) }
    { platform:iOS Simulator, id:061643FA-9B0F-4810-A527-27834CFB56BE, OS:15.5, name:iPod touch (7th generation) }
    { platform:iOS Simulator, id:E66C852C-AABF-4962-BFE6-3875DB994D80, OS:15.5, name:iPad (9th generation) }
    { platform:iOS Simulator, id:86B696F1-2B21-44AD-A196-6DECB79997C2, OS:15.5, name:iPad Air (5th generation) }
    { platform:iOS Simulator, id:2CFA9EC2-8536-4896-AB2C-4B4433A83B1A, OS:15.5, name:iPad Pro (9.7-inch) }
    { platform:iOS Simulator, id:55A7E9F6-D9A4-403F-86E8-6C11333E18CA, OS:15.5, name:iPad Pro (11-inch) (3rd generation) }
    { platform:iOS Simulator, id:9FE971FA-B748-4992-9A16-4BB84AC0874F, OS:15.5, name:iPad Pro (12.9-inch) (5th generation) }
    { platform:iOS Simulator, id:33FB6D7A-201D-436F-B707-9099E0C259D2, OS:15.5, name:iPad mini (6th generation) }
    ** BUILD FAILED **


Xcode's output:
↳
    Command CompileSwiftSources failed with a nonzero exit code
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:26:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:30:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:36:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:42:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:82:13:
    warning: switch must be exhaustive
                switch code {
                ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:82:13: note:
    add missing case: '.notInteractive'
                switch code {
                ^
    remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:26:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:30:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:36:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:42:6: error:
    enum cases with associated values cannot be marked potentially unavailable with '@available'
        @available(iOS 13.0, macOS 10.15, *)
         ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:82:13:
    warning: switch must be exhaustive
                switch code {
                ^
    /Users/lihao/install_home/flutter/.pub-cache/hosted/pub.flutter-io.cn/sign_in_with_apple-2.5.4/ios/Classes/SignInWithAppleError.swift:82:13: note:
    add missing case: '.notInteractive'
                switch code {
                ^
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'webview_flutter' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'wakelock' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'video_player' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'url_launcher' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'uni_links' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'sign_in_with_apple' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'shared_preferences' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'path_provider' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'nanopb' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'jpush_flutter' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'image_picker' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'fluttertoast' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'flutter_secure_storage' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'firebase_core' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'firebase_analytics' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'device_info' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'Toast' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'GoogleUtilities' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'GoogleDataTransport' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FirebaseInstallations' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FirebaseCoreDiagnostics' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FirebaseCore' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FMDB' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'Firebase' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'JPush' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'Flutter' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'JCore' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FirebaseAnalytics' from project 'Pods')
    /Users/lihao/app_code/tn-oeyes-app/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the
    range of supported deployment target versions is 9.0 to 15.5.99. (in target 'GoogleAppMeasurement' from project 'Pods')

背景

原本项目好好的, 但是发布新版本的时候 xcode提示我需要升级最新版本 xcode13以支持ios15
于是花了半天升级mac系统到12.4 xcode13.4.1
升级好的那一刻感觉胜利将要来临,结果发现才是噩梦的开始...
刚开始我还以为是什么版本的问题 比如由8.0改成9.0,这里直接告诉你,不是!!!
先按照我下面说的做, 解决了就能节省你好多研究时间,不能解决你再慢慢肝儿~不是么?

问题解决

解决历程就不细讲了,
主要就是 插件 sign_in_with_apple: ^2.5.4 里面的语法可能在升级了13后报错了,
(当然你有可能是其它插件)
sign_in_with_apple新版本已经解决了这个问题

两个解决方案:

方案一

如果你的flutter版本是2.0, 建议你直接升级sign_in_with_apple到最新版本
我们现在用的1.0版本的flutter, 但是!! 现在插件新版本都需要flutter2.0,所以我采用的是方案二

方案二 (如果你是flutter1.0)

直接使用github里面修改版,反正你也不升级 flutter2.0了不是?
(原版链接是https://github.com/risdeit/dart_packages,我的是fork他的,防止他的删库)

  sign_in_with_apple:
    git:
      url: https://github.com/lihhhh/dart_packages.git
      path: packages/sign_in_with_apple
      ref: 4d39321
image.png

最后

运行下面代码,完美搞定!

flutter clean
flutter build ios

如果还不行你可以试试下面命令,由上至下, 注意先备份文件

sudo gem uninstall cocoapods
brew uninstall cocoapods
sudo gem install cocoapods
pod setup
flutter pub upgrade
pod update
rm -rf ios/Flutter/Flutter.framework
rm ios/Flutter/Flutter.podspec
rm -f ios/Podfile.lock
flutter clean
flutter build ios

你可能感兴趣的:(Flutter打包IOS15报错@available(iOS 13.0, macOS 10.15, *))