Flutter:无法构建 iOS 应用程序 "ARCHIVE FAILED",为设备存档时遇到错误

Flutter : Failed to build iOS app "ARCHIVE FAILED",Encountered error while archiving for device

我试图生成 ipa 文件以将其上传到 App Store,但不幸的是它失败了,并显示“为设备存档时遇到错误”。 我也尝试从 Xcode 存档,但是存档也在那里失败了。它在 ios 模拟器 (13)

中运行良好

无法构建 iOS 应用 Xcode 构建的错误输出: ↳ ** 归档失败 **

Xcode 的输出: 在路径写入结果包:

    /var/folders/8s/2st2j0d97k7cm80h3968jnx80000gn/T/flutter_tools.ph1v
            kd/flutter_ios_build_temp_dirZbRdRw/temporary_xcresult_bundle
    
        error: the following command failed with exit code 0 but produced no
        further output
        CompileC
        
Failed to package /Users/sunsoft/Downloads/alifpet-app-master.
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'Sodium' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'ReachabilitySwift' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'Starscream' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/ios/Pods/Pods.xcodeproj:
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is
    set to 6.0, but the range of supported deployment target versions is
    9.0 to 15.2.99. (in target 'Reachability' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/ios/Pods/Pods.xcodeproj:
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is
    set to 7.0, but the range of supported deployment target versions is
    9.0 to 15.2.99. (in target 'AppAuth' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'PusherSwiftWithEncryption' from project
    'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'GoogleSignIn' from project 'Pods')
    /Users/sunsoft/Downloads/alifpet-app-master/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.2.99. (in target 'AgoraRtcEngine_iOS' from project 'Pods')

    Result bundle written to path:
        /var/folders/8s/2st2j0d97k7cm80h3968jnx80000gn/T/flutter_tools.ph1v
        kd/flutter_ios_build_temp_dirZbRdRw/temporary_xcresult_bundle
    
    Encountered error while archiving for device.

这里的问题是 Flutter 模板默认创建的 Podfile 不幸的是没有特定的 iOS 版本设置。

执行此操作以解决此问题:

  1. 在项目的 ios/ 文件夹中,打开 Podfile.
  2. Podfile 的顶部,确保此行 未被 注释掉,并将 iOS 版本更改为 12.0。

更改自:

#platform :ios, '8.0'

至:

platform :ios, '12.0'
  1. 运行 pod deintegrate 在您项目的 ios/ 文件夹内的终端中。

  2. 运行 pod install --repo-update 在您的 ios/ 文件夹中

这应该可以解决问题![​​=21=]

如果在此之后您收到以下错误

CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target

然后你需要在 Xcode 中打开你的 iOS 工作区,在左上角 select 你的根项目,然后在信息选项卡中,选择你的配置(在本例中是调试) 并将其更改为 None。之后,再次执行 pod install。

我在使用命令 flutter build ipa --release --no-tree-shake-icons 构建时遇到此错误,而当我使用 xcode.

存档时它工作正常
Result bundle written to path:
    /var/folders/ds/bbptl8p5391_lg2drzvrgt3w0000gn/T/flutter_tools.VLOTC5/flutter_ios_build_temp_d
    ir8SL9Nl/temporary_xcresult_bundle

未分类 (Xcode):已退出,状态代码为 1

归档设备时遇到错误。