Flutter在Mac模拟器执行flutter run时触发XCode链接错误求助
解决Flutter iOS模拟器编译时libarclite_iphonesimulator.a缺失问题
检查Xcode命令行工具配置
打开终端执行xcode-select --print-path,确认输出为/Applications/Xcode.app/Contents/Developer。如果不是,执行sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer。之后打开Xcode,完成许可协议确认和组件安装(首次打开会自动提示)。修复工具链文件缺失
先通过ls /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/确认文件是否存在。如果确实缺失,可通过以下两种方式处理:- 创建软链接:
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libarclite_iphoneos.a /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a - 修改iOS部署目标:
打开项目的ios/Podfile,找到platform :ios, '11.0'(或当前设置的版本),修改为platform :ios, '14.0'(或更高,匹配模拟器的iOS 16.4)。然后执行:cd ios && pod deintegrate && pod install && cd ..
- 创建软链接:
清理缓存重建项目
依次执行以下命令:flutter clean rm -rf ios/Pods ios/Podfile.lock flutter pub get cd ios && pod install && cd .. flutter run检查版本兼容性
Flutter 3.7.0建议搭配Xcode 14.1及以上版本,若你的Xcode版本低于此,升级到最新兼容版本(通过App Store或苹果开发者网站下载),升级后重新配置Xcode命令行工具。
内容的提问来源于stack exchange,提问作者Sebastian Cocîrlă
相关产品推荐
相关产品推荐

