报错场景及处理方案
持续更新中...
ios-解决报错-CocoaPods could not find compatible versions for pod “xxx“
场景:使用某个三方库时,跑在IOS上报错。
最近在用Flutter做健康相关的App,需要用到Healthykit
,就找到了health
这个库。最后运行在ios上时,直接报错。提示CocoaPods could not find compatible versions for pod "health"。
原因: 打开ios项目中的ios/Pods/Local Podspecs/
目录,这里面存储的是所有pubspec.yaml
中使用的了的三方库配置信息,因为我这个项目是因为health
这个库而引起的问题,所以打开health.podspec.json
,在最下面可以看到以下内容:
"platforms": {
"ios": "13.0"
},
这个库要求ios的最低版本在13.0。而我的项目还没有指定最低版本,默认就使用了9.0来编译。所以会提示不兼容。
解决方案:打开ios/Podfile
文件,将第二行的内容去掉注释。将后面的版本改为上面库里面对应的版本即可。
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '13.0'
因为health
最低要求13.0,所以在这里改成13.0即可。最后重新运行,等待pod install
、xcode build
之后,就能成功运行起来了。
Invalid depfile: xxx/.dart_tool/xxx
Invalid depfile: /Users/xxx/xxx/xxx/.dart_tool/flutter_build/b8e049ba8d761454beb71a0a8427574d/kernel_snapshot.d
这个错误通常在 Flutter 开发中可能会遇到。该错误指向一个无效的依赖文件(depfile),可能是由于某种原因导致的构建问题。为了解决这个问题,你可以尝试以下几个步骤:
- 1.清理缓存:
flutter clean
- 2.删除
.dart_tool
文件夹:rm -rf .dart_tool
或者在 Windows 系统中:rmdir /s /q .dart_tool
- 3.拉取依赖:
flutter pub get
打包
可视化操作
修改APP版本
修改jsbundle版本
修改打包方式为release,Product -> Scheme -> Edit Scheme
- 3.打包
设备选择Any iOS DeviceProduct -> Archive,等待约10分钟出来。此时我们选择最新包,然后Disttibute App
这里内测包我们选Ad Hoc。如果上线包选App Store Connect
然后一路Next到证书这里,这里我们根据需要选择开发证书
最后得到包
打包app
flutter build ios --release
打包ipa
flutter build ipa --export-method app-store
flutter build ipa --export-method ad-hoc
flutter build ipa --export-method development
flutter build ipa --export-method enterprise
内测ipa包添加UDID
- 1.点开蒲公英按照引导扫码,蒲公英 | 一步快速获取 iOS 设备的UDID (pgyer.com)
- 2.登录苹果开发者中心
- 选择“Certificates, Identifiers & Profiles”(证书、标识符和配置文件)。
- 选择“Devices”(设备),然后点击“+”按钮添加设备。
- 输入设备名称和UDID,然后点击“Continue”(继续)。
- 确认设备信息后,点击“Register”(注册)。
- 设备添加成功后,可以在“Devices”页面查看设备信息。
- 3.重新打包,执行命令
flutter build ipa --export-method ad-hoc
打包证书问题
遇到证书问题,可以尝试删除本地所有证书。即该文件下所有文件
open ~/Library/MobileDevice/Provisioning\ Profiles
然后 Xcode -> Setting,然后选中证书点击下载
再次打开证书文件夹,发现已经更新