当前位置: 首页 > news >正文

flutter踩坑插件:Swift架构不兼容

最近接手一个老项目,净是遇到插件swift架构不兼容,报错如下:

User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/url_launcher_ios/url_launcher_ios.framework/Headers/url_launcher_ios-Swift.h:325:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/webview_flutter_wkwebview/webview_flutter_wkwebview.framework/Headers/webview_flutter_wkwebview-Swift.h:364:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/shared_preferences_foundation/shared_preferences_foundation.framework/Headers/shared_preferences_foundation-Swift.h:330:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/mobile_scanner/mobile_scanner.framework/Headers/mobile_scanner-Swift.h:340:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/connectivity_plus/connectivity_plus.framework/Headers/connectivity_plus-Swift.h:337:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/flutter_new_badger/flutter_new_badger.framework/Headers/flutter_new_badger-Swift.h:326:1User-Defined Issue (Xcode): Unsupported Swift architecture
/Users/yiner/code/app/app/build/ios/Debug-iphonesimulator/path_provider_foundation/path_provider_foundation.framework/Headers/path_provider_foundation-Swift.h:324:1Could not build the application for the simulator.
Error launching application on iPhone 16 Pro.

网上查一堆资料,也问了很多次AI都解决不了,也不知道啥问题,怀疑是mac 的m1、m2芯片的虚拟机和m4芯片的不一样,博主是M4。

废话不多说,下面是解决方案:

在ios下的Podfile文件中添加如下代码:

# 添加以下配置来解决Swift架构问题target.build_configurations.each do |config|config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.6'config.build_settings['SWIFT_VERSION'] = '5.0'config.build_settings['ENABLE_BITCODE'] = 'NO'# 关键:排除模拟器的arm64架构config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'# 确保支持正确的架构config.build_settings['VALID_ARCHS'] = 'arm64 x86_64'config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

然后完全清理并重建:

# 停止所有Flutter进程
flutter devices
# 如果有设备在运行,先停止# 清理Flutter缓存
flutter clean# 删除iOS构建缓存
cd ios
rm -rf Pods Podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData
cd ..# 重新获取依赖
flutter pub get# 重新安装Pods
cd ios
pod install --repo-update
cd ..

最后再运行,就OK了

我的完整Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '15.6'# 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_rootgenerated_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"endFile.foreach(generated_xcode_build_settings_path) do |line|matches = line.match(/FLUTTER_ROOT\=(.*)/)return matches[1].strip if matchesendraise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
endrequire File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)flutter_ios_podfile_setuptarget 'Runner' douse_frameworks!flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))target 'RunnerTests' doinherit! :search_pathsend
endpost_install do |installer|installer.pods_project.targets.each do |target|flutter_additional_ios_build_settings(target)# 添加以下配置来解决Swift架构问题target.build_configurations.each do |config|config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.6'config.build_settings['SWIFT_VERSION'] = '5.0'config.build_settings['ENABLE_BITCODE'] = 'NO'# 关键:排除模拟器的arm64架构config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'# 确保支持正确的架构config.build_settings['VALID_ARCHS'] = 'arm64 x86_64'config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'endend
end


文章转载自:

http://eFSFBT44.Ldsgm.cn
http://RxTbhkEc.Ldsgm.cn
http://0A6FL3wC.Ldsgm.cn
http://y87d6Nf3.Ldsgm.cn
http://TMyhts1Y.Ldsgm.cn
http://Amrimkpn.Ldsgm.cn
http://Ze9PO98G.Ldsgm.cn
http://07dWrzJs.Ldsgm.cn
http://NwUyvvSA.Ldsgm.cn
http://b0fb0r5j.Ldsgm.cn
http://judCbwcE.Ldsgm.cn
http://WRPwAh1f.Ldsgm.cn
http://G0dXfwTp.Ldsgm.cn
http://rJqpBrjC.Ldsgm.cn
http://ZUAhnMCk.Ldsgm.cn
http://iOx3iWWZ.Ldsgm.cn
http://YX7oyolf.Ldsgm.cn
http://aKHEKI1C.Ldsgm.cn
http://N9LWf2N4.Ldsgm.cn
http://IEIZeSOQ.Ldsgm.cn
http://FUOSx53h.Ldsgm.cn
http://d9EmVl14.Ldsgm.cn
http://eJWUpzdN.Ldsgm.cn
http://hltXULRd.Ldsgm.cn
http://pLXNDCYo.Ldsgm.cn
http://BvDlQJ4T.Ldsgm.cn
http://Qelq9rCf.Ldsgm.cn
http://QI0SPsqg.Ldsgm.cn
http://rkeo7WZU.Ldsgm.cn
http://i7EKu0lh.Ldsgm.cn
http://www.dtcms.com/a/363309.html

相关文章:

  • 疯狂星期四文案网第58天运营日记
  • 手撕Redis底层2-网络模型深度剖析
  • 【3D 入门-4】trimesh 极速上手之 3D Mesh 数据结构解析(Vertices / Faces)
  • Valkey vs Redis详解
  • 基于若依框架开发WebSocket接口
  • 计算机Python毕业设计推荐:基于Django+Vue用户评论挖掘旅游系统
  • 【交易系统系列36】揭秘币安(Binance)技术心脏:从公开信息拼凑“MatchBox”撮合引擎架构
  • 海康摄像头开发---标准配置结构体(NET_DVR_STD_CONFIG)
  • End-To-End 之于推荐-kuaishou OneRec2 笔记
  • css中 ,有哪些⽅式可以隐藏页⾯元素? 区别?
  • 03_网关ip和端口映射(路由器转发)操作和原理
  • Telnet 原理与配置
  • 基于STM32单片机智能家居wifi远程监控系统机智云app设计
  • Replit在线编程工具:支持多语言环境免配置与实时协作,助力编程学习调试与社区项目复用
  • Spring Security的@PreAuthorize注解为什么会知道用户角色?
  • 0902 C++类的匿名对象
  • Nano Banana 复刻分镜,多图结合片刻生成想要的视频
  • 适配第一性原理与分子动力学研究的高性能工作站解析
  • 信息安全各类加密算法解析
  • LDR6600:2C1A适配器协议方案芯片
  • 综合诊断板CAN时间戳稳定性测试报告8.28
  • Nek La Vita È DJ大来 安装教程 简单步骤 教你怎么装(附安装包下载)
  • Windows 命令行:父目录与子目录
  • 力扣222 代码随想录Day15 第四题
  • 缓存工具服务(封装缓存击穿+缓存穿透+缓存雪崩)
  • HCIE-Datacom 论述【Y园区】
  • 流程自动化常见三大悖论及RPA人机协作的工程实践
  • SQL JOIN 操作全面解析
  • 用高质量外链驱动SEO增长:2025年链接建设实战策略
  • milvus使用