在 Flutter 2 和 XCode 12.5 更新后发生的 Flutter unknown iOS 构建中的错误

Posted

技术标签:

【中文标题】在 Flutter 2 和 XCode 12.5 更新后发生的 Flutter unknown iOS 构建中的错误【英文标题】:Error in Flutter unknown Error in iOS build, occurred after Flutter 2 and XCode 12.5 update 【发布时间】:2021-06-11 11:09:37 【问题描述】:

我的应用程序一直在运行,并且将在 androidios 上发布,但几天前在我更新到 Flutter 2.0 和 XCode 12.5 后,“flutter run”仅在 iOS 中失败。 我将 XCode 降级到 12.4 仍然无法正常工作。

Development: Shivam Srivastava (67UX3WD5D5)"
Running pod install...                                              7.8s
Running Xcode build...                                                  
Xcode build done.                                           88.3s
Failed to build iOS app
Error output from Xcode build:
↳
    2021-06-11 16:26:19.761 xcodebuild[968:9748]
    CFURLRequestSetHTTPCookieStorageAcceptPolicy_block_invoke: no longer
    implemented and should not be called
    ** BUILD FAILED **


Xcode's output:
↳
    lib/widgets/PdfRender.dart:14:8: Error: Error when reading
    '../../../flutter/.pub-cache/hosted/pub.dartlang.org/pdf_render-1.0.11/lib/p
    df_render_widgets2.dart': No such file or directory
    import 'package:pdf_render/pdf_render_widgets2.dart';

【问题讨论】:

我认为您需要更新 ios 文件夹中的 AppFramework.plist 部署目标。我以前遇到过这个问题。 Podspec 文件应该被删除并使用flutter clean。 Pod repo update 然后确保您更新了 AppFramework.plist 和 Info.plist 上的部署目标。它应该可以工作。 我用最新的 Flutter 和 xcode 重新创建了项目,我尝试删除 podfile、pods 并使用 pod init、安装、更新多次无效,用 podfile 更新了问题 已解决,包升级和项目中要更新的新包配置 【参考方案1】:

运行对我有用的 pod update 有需要更新的包。 同样的事情发生了我的应用程序没有构建我运行 flutter clean 然后 flutter pub get 然后 pod update 为我解决了它。

【讨论】:

试过不行,尝试了所有基本的东西,更新pod,检查证书,从头开始创建新项目 lib/widgets/PdfRender.dart:14:8 what is the code error at this line 我认为这与第二行错误无关,不断变化,未能构建应用程序导致继续错误【参考方案2】:

我的 pod 文件看起来像这样并且完美运行

# Uncomment this line to define a global platform for your project
platform :ios, '12'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', 
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,


def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#generated_xcode_build_settings_path must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #generated_xcode_build_settings_path. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
 installer.pods_project.targets.each do |target|
   flutter_additional_ios_build_settings(target)
   target.build_configurations.each do |config|
     config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.3'
     config.build_settings['ENABLE_BITCODE'] = 'YES'
     config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
             '$(inherited)',
     # dart: PermissionGroup.camera
     'PERMISSION_CAMERA=1',

     # dart: PermissionGroup.microphone
     'PERMISSION_MICROPHONE=1',

     # dart: PermissionGroup.photos
     'PERMISSION_PHOTOS=1',

     # dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
     'PERMISSION_LOCATION=1',

     # dart: PermissionGroup.notification
     'PERMISSION_NOTIFICATIONS=1',

     ]
   end
   installer.pods_project.build_configurations.each do |config|
       config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
   end
 end
end


# target 'ImageNotification' do
#   use_frameworks!
#
#   pod 'Firebase/Messaging'
# end

【讨论】:

以上是关于在 Flutter 2 和 XCode 12.5 更新后发生的 Flutter unknown iOS 构建中的错误的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Flutter 中使用 Xcode 12.5 解决 Stripe 支付问题?

SmartConfig 在升级到 Xcode 12.5 后停止工作

升级到 Xcode 12.5 后的 xcodebuild 问题

最新版本的 Xcode 安装时卡住了 (12.5)

为啥 Xcode 12.5 `xcodebuild -archive` 抱怨在没有 AppClip 的应用程序中缺少 appclip 权利?

Xcode12.5 新特性介绍