解决Error (Xcode): File not found:XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a

出现场景

一个老项目在最新的Xcode14.3运行报以下错误。

Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: YE6STNG83Y
Running Xcode build...
Xcode build done.                                            8.9s
Failed to build iOS app
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)


Error launching application on iPhone.

根据网上的资料,这是由于 Xcode14只支持构建ios11.0及以上的版本。libarclite对于老的版本才需要,在IOS11以上被废弃了。所以我们要确保所有的库的构建目标都要在11.0以上。

解决方案

方案1

打开Xcode, 选中Pods,查看Targets中库有哪些是大于11.0的,改为11.0。然后重新运行即可。
解决Error (Xcode): File not found:XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a_第1张图片

方案2

如果方案1不行,那就手动添加以下代码到Podfile中,然后重新编译。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
  # 添加以下代码
  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
end

你可能感兴趣的:(CocoaPods问题集合,xcode,ios,iphone,cocoapods)