修复Flutter一些iOS编译错误

修复Flutter一些iOS编译错误

Сocoapods trunk URL couldn't be downloaded

逐行运行此命令

shell 复制代码
gem uninstall cocoapods 
arch -x86_64 brew install cocoapods 
arch -x86_64 brew reinstall cocoapods 
cd ios 
pod cache clean --all 
pod install (如果m1 macOS 运行这个"arch -x86_64 pod install")
pod update

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target Runner to Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig or include the Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig in your build configuration (Flutter/Release.xcconfig).

  1. 我们首先用Xcode打开ios/Runner.xcworkspace
  2. 然后选中Project Navigator下的Runner项目,再选中PROJECT下面的Runner,再然后选中Info
  3. 我们找到Configurations,把DebugReleaseProfile下面的Runner/Runner全部选为None;
  4. 再一次运行pod update,警告消息。

需要注意的是,如果运行了pod update之后,选项会被自动勾选为Pods-Runner.debug或者Pods-Runner.release,在这个选项之下,会报错:

Command PhaseScriptExecution failed with a nonzero exit code

如果需要解决这个报错,只需要修改为Debug或者Release即可消除。

Framework 'Pods_Runner' not found

  1. 删除掉ios文件夹下面的Podfile文件;
  2. 在项目的文件夹下,按顺序运行flutter cleanflutter pub get命令,它将会重新生成Podfile文件;
  3. 在新的Podfile文件中的# platform :ios, '12.0'的版本号修改为14.0,并取消掉注释:platform :ios, '14.0';
  4. ios文件夹下运行pod install命令。

根据我实际的测试,我发现这个问题很奇怪,实际上,不需要上面步骤那么复杂,只要触发了这个编译错误,你只需要执行一次 步骤2和4即可,再编译就不会出现这个错误了。

这个时候,一切就都正常了。

我在Intel芯片的Macbook上没有问题,但是在ARM的M2芯片下碰到的这个问题。

参考资料

相关推荐
Irene19911 小时前
ElementPlus 与成熟后台框架对比:vue-element-plus-admin、vue-pure-admin等
前端·ui·框架·vue3
尘中客5 小时前
放弃 Echarts?前端直接渲染后端高精度 SVG 矢量图流的踩坑记录
前端·javascript·echarts·前端开发·svg矢量图·echarts避坑
FreeBuf_5 小时前
Chrome 0Day漏洞遭野外利用
前端·chrome
小彭努力中5 小时前
199.Vue3 + OpenLayers 实现:点击 / 拖动地图播放音频
前端·vue.js·音视频·openlayers·animate
2501_916007475 小时前
网站爬虫原理,基于浏览器点击行为还原可接口请求
前端·javascript·爬虫·ios·小程序·uni-app·iphone
前端大波6 小时前
Sentry 每日错误巡检自动化:设计思路与上手实战
前端·自动化·sentry
ZC跨境爬虫7 小时前
使用Claude Code开发校园交友平台前端UI全记录(含架构、坑点、登录逻辑及算法)
前端·ui·架构
慧一居士7 小时前
Vue项目中,何时使用布局、子组件嵌套、插槽 对应的使用场景,和完整的使用示例
前端·vue.js
Можно7 小时前
uni.request 和 axios 的区别?前端请求库全面对比
前端·uni-app
星辰即远方7 小时前
OC学习Foudation框架
学习·ios·objective-c