React Native iOS执行pod install时找不到RNPermissions依赖的问题
解决React Native iOS pod install时RNPermissions依赖缺失问题
问题重现
执行以下命令时触发报错:
$ cd ios $ pod install
报错核心内容:
!Unable to find a specification for `RNPermissions` depended upon by `Permission-LocationAlways` You have either: -mistyped the name or version. -not added the source repo that hosts the Podspec to your Podfile.
解决方案
针对同环境其他机器可正常执行、仅本地报错的情况,按以下步骤排查:
清理CocoaPods本地缓存
本地缓存可能存在损坏或过期的spec文件,执行命令彻底清理:pod cache clean --all也可以手动删除缓存目录:
rm -rf ~/.cocoapods/repos更新CocoaPods仓库
确保本地spec仓库与远程同步:pod repo update确认依赖包与Podfile配置
- 先确认
react-native-permissions已正确安装到项目:npm install react-native-permissions - 打开iOS目录下的
Podfile,确保添加了正确的官方源:source 'https://cdn.cocoapods.org/' - 若自动链接未生效,手动添加RNPermissions的路径引用(适配React Native 0.63版本):
pod 'RNPermissions', :path => '../node_modules/react-native-permissions'
- 先确认
重置项目Pod依赖文件
进入iOS目录,删除残留的Pod配置文件后重新安装:cd ios rm -rf Pods Podfile.lock pod install验证Xcode命令行工具版本
确保Xcode命令行工具与当前使用的Xcode版本匹配:xcode-select --print-path若路径不正确,切换到正确的Xcode目录:
xcode-select --switch /Applications/Xcode.app/Contents/Developer
内容的提问来源于stack exchange,提问作者manoj chandola
相关产品推荐
相关产品推荐

