M1芯片Mac下Flutter iOS项目用xcworkspace运行报x86_64架构符号未定义错误
M1芯片Mac Flutter iOS xcworkspace运行链接错误解决方案
方案1:统一配置架构排除规则
- 打开
Runner.xcworkspace,选中根目录下的Runner项目,进入TARGETS > Runner > Build Settings页面 - 搜索
Excluded Architectures,在Debug、Release模式下,为Any iOS Simulator SDK配置值为arm64 - 在
ios/Podfile末尾添加以下配置,自动同步所有Pods依赖的架构规则,避免每次手动修改Pods配置:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| # 排除模拟器下的arm64架构,适配M1转译运行 config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' end end end
方案2:使用Rosetta模式重新安装依赖
- 右键点击终端应用,选择「显示简介」,勾选「使用Rosetta打开」后重启终端
- 按顺序执行以下清理重装命令:
flutter clean rm -rf ios/Podfile ios/Podfile.lock pubspec.lock ios/Pods ios/Runner.xcworkspace flutter pub get cd ios pod install --repo-update cd ..
- 命令执行完成后重新运行项目即可。
方案3:升级fluttertoast插件版本
当前报错指向fluttertoast插件的符号缺失,旧版本插件未适配M1芯片模拟器运行,直接在pubspec.yaml中将fluttertoast升级到最新稳定版即可:
dependencies: flutter: sdk: flutter fluttertoast: ^8.2.4
修改完成后执行flutter pub get,再重新编译项目。
方案4:临时规避方案
如果上述方案仍未解决,可直接选择iOS真机运行项目,真机不存在x86_64架构兼容问题,可正常编译运行。
内容的提问来源于stack exchange,提问作者Anurag kanakapalli
相关产品推荐
相关产品推荐

