更新 flutter 和 Xcode 后,Xcode 14.3 中缺少文件“libarclite_iphoneos.a”

Ell*_*let 71 xcode ios flutter flutter-ios-build xcode14

我有 flutter 项目,我正在尝试运行 iOS 版本,但在将 flutter 和 Xcode 更新到最新版本后出现错误,我使用 firebase core 插件

错误:

Could not build the precompiled application for the device.
Error (Xcode): File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

播客文件:

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

# 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)
  end
end
Run Code Online (Sandbox Code Playgroud)

我还尝试通过以下方式安装所有已安装的 Pod:

pod deintegrate
rm Podfile.lock
rm -rf Pods
Run Code Online (Sandbox Code Playgroud)

然后更新存储库并安装 pod,我仍然遇到相同的错误,我应该重新安装 xcode 吗?

颤振包:

firebase_core: ^2.8.0
firebase_crashlytics: ^3.0.17
firebase_analytics: ^10.1.6
firebase_messaging: ^14.3.0
Run Code Online (Sandbox Code Playgroud)

有什么解决方法吗?感谢您抽出时间

小智 57

post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
         end
    end
end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
Run Code Online (Sandbox Code Playgroud)

尝试更新您的 ios/Podfile。将 13.0 更改为文件顶部的版本。

  • 我会尝试,但是你能详细解释一下这里发生了什么吗?感谢您的时间 (5认同)
  • 我尝试了这个并且它有效,但我不确定这是否是一个好的解决方案,我不是原生ios开发人员,我只熟悉flutter和原生android,所以你能给我们解释一下发生了什么吗在?问题是什么,为什么会发生,你是如何解决的?非常感谢您的宝贵时间 (5认同)
  • 它解决了编译问题(我们使用 11.0,因为这是我们的最低要求),构建但随后在存档时失败,并显示 ```ios/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/openssl_grpc.framework" failed: No这样的文件或目录 (2)``` (3认同)

Ell*_*let 28

新答案(编辑4)

如果您升级 Flutter 和 cocoa pod 以及 Flutter 插件后仍然遇到此问题,一个非常简单且有效的解决方案是编辑您的 Podfile

 platform :ios, '14.0'

# 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__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

#post_install do |installer|
#  installer.pods_project.targets.each do |target|
#    flutter_additional_ios_build_settings(target)
#  end
#end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']) < Gem::Version.new('13.0')
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
      end
    end
    flutter_additional_ios_build_settings(target)
  end
end
Run Code Online (Sandbox Code Playgroud)

我所做的更改是将平台 ios 版本定义为最低 14,并确保所有 pod 至少有 13 最低版本,否则忽略它,更改是针对第二行和最后的post_install

旧答案(编辑1、2和3)

我解决了这个问题,尽管我不确定这是否是一个好的解决方案,但请运行以下命令:

flutter clean
flutter pub get
cd ios/
pod deintegrate
pod install
pod repo update
pod install (again)
Run Code Online (Sandbox Code Playgroud)

只需在 Xcode 中打开 flutter 项目内的 ios 项目,转到文件夹(文件)选项卡中的 Pods,转到目标,转到导致问题的目标(我猜是 pod,一个依赖项),在我的例子中是FMDB和 App auth将两者的最低部署从当前版本(在我的例子中为 9.0)升级到 13.0,并尝试通过构建应用程序并在 Xcode 中运行它或使用选定的 ios 设备使用 flutter run 来再次运行应用程序,问题应该消失

然而有时当你在 flutter 中清理项目时(使用flutter clean),它会重置这些更改,或者当你删除 pod 并分解 Cocapods 并重新安装应用程序时,所有更改都将恢复为默认值,这并不是真正的更改。有效的解决方案,但至少你可以运行该应用程序

如果问题仍然存在,请再次更新 pods 目标的最小部署并使用 Xcode 运行应用程序,如果问题仍然存在,请尝试其他答案,或者您可以尝试通过以下方式更新 cocapods

sudo gem install cocoapods
Run Code Online (Sandbox Code Playgroud)

如果你的Mac机器是苹果硅(m1,m2),你还需要运行

sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
Run Code Online (Sandbox Code Playgroud)

官方文档说

编辑:这个解决方案的想法出现在我的脑海中,这一切都归功于@Siyu

如果你来自未来,你可能想尝试升级软件包和 cocapods、flutter 等......

编辑2:

尝试更新 Flutter,因为该问题应该在 3.7.11 中得到解决

flutter upgrade
Run Code Online (Sandbox Code Playgroud)

编辑3:

这个问题在 flutter 3.10 中再次出现,有一些软件包,所以请使用我使用的方式或尝试其中一个答案并尝试理解它,谢谢您的时间,祝您好运

  • 谢谢你 - 我只想补充一点,我进行了 flutter 升级,然后安装了 arch -x86_64 pod(在 M1 上),这就是截至 2023 年 4 月 17 日所需的全部内容 (2认同)

Mas*_* .H 20

更新:该问题已在以后的 Flutter 版本运行中解决

flutter upgrade并重新初始化依赖项

flutter clean
flutter pub get
cd ios/
pod deintegrate
pod install
pod repo update
pod install
Run Code Online (Sandbox Code Playgroud)

如果无法解决错误,请按照下面提到的步骤操作

确保您已更新 pod 文件,然后按照以下步骤操作:

步骤1

在我的案例中跟踪库所遇到的问题,我收到 FMDB 文件错误在此输入图像描述

第2步

使用下拉菜单更改受影响 Pod 上的 iOS 版本(蓝色小箭头) 在此输入图像描述

步骤3

更改目标 Pod 上的分发设置在此输入图像描述

在 Xcode 上再次重建您的应用程序。并重复该过程,直到解决所有库问题

  • 此更改将暂时起作用,但下次 Flutter 工具调用“pod install”时将被覆盖(如果您运行“flutter clean”,向 pubspec 添加新插件等)。无需手动更新,而是运行“flutter Upgrade”以获取 Flutter 3.7.11 中的 Xcode 14.3 行为更改解决方法 https://github.com/flutter/flutter/issues/124340。 (3认同)

Mar*_*ler 7

也面临这个问题并走上了同样的道路。

  1. 不幸的是,将部署目标升级到 13.0 只能解决应用程序调试版本的问题。然后,您至少可以再次在模拟器中运行它。

  2. 由于 CocoaPods ,归档应用程序(例如构建 ipa 以提交到商店)目前在 Xcode 14.3 中仍将失败(从 xCode 14.2 升级到 14.3 PhaseScriptExecution 失败,退出代码为非零)。不幸的是,目前(唯一?)的解决方案似乎正在降级到 14.2,同时等待 CocoaPods 方面的修复(https://github.com/CocoaPods/CocoaPods/issues/11808#issuecomment-1481244508

更新 该问题似乎已被发现并修复(https://github.com/CocoaPods/CocoaPods/pull/11828),但尚未合并 - 希望这很快就会发生。与此同时,在 ...framework.sh 文件中将source="$(readlink "${source}")" 替换为 source="$(readlink -f "${source}")" 似乎有所帮助。

  • 您好,您能否更详细地告诉我,用 source="$(readlink -f "${source}")" 替换 source="$(readlink "${source}")" 到底意味着什么,在哪里更改它以及如何 ?怎样才能做到呢? (2认同)

Jen*_*enn 6

最初报告的缺失libarclite_iphoneos.a编译失败是当 Flutter 插件具有最低 iOS 版本 < 9.0 的依赖项(CocoaPods pod)时引起的。Xcode 14.3 似乎从构建这些较低版本所需的工具链中删除了一个库。 Flutter 3.7.11为 iOS 和 macOS 提供了解决方法。更多详细信息请参见https://github.com/flutter/flutter/issues/124340

这些答案中讨论的另一个(不相关)问题是无法存档 iOS 或 macOS 应用程序。这是由于不同的 Xcode 14.3 行为更改破坏了 CocoaPods 脚本https://github.com/CocoaPods/CocoaPods/issues/11808。Flutter 中有一个解决方法,可在https://github.com/flutter/flutter/issues/123890中跟踪,并在Flutter 3.7.10中提供。

如果您遇到任一问题,请运行flutter upgrade以获取包含这些修复的最新版本的 Flutter。如果您仍然遇到问题,请提交新的 GitHub 问题,我或其他 Flutter 维护人员将会查看。


小智 5

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/

sudo mkdir arc
cd  arc
sudo git clone https://github.com/kamyarelyasi/Libarclite-Files.git .

sudo chmod +x *
Run Code Online (Sandbox Code Playgroud)

这对我有用。