问题描述
- 当两个组件依赖了同一个三方库的
不同版本
,在执行pod install
时会报如下错误
[!] CocoaPods could not find compatible versions for pod "Bugly":
In Podfile:
Bugly (= 2.5.1)
XXXIMSDK (from `../XXXIMSDK`) was resolved to 2.11.3, which depends on
Bugly (~> 2.5.2)
Specs satisfying the `Bugly (= 2.5.1), Bugly (~> 2.5.2)` dependency were found,
but they required a higher minimum deployment target.
解决办法
- 方法1:简单粗暴地将版本改为同一个版本,这个没什么好说的
- 方法2:使用模糊的版本限制
pod 'AFNetworking' // 始终依赖最新版本
pod 'AFNetworking', '~>0' // 等价上面的写法
pod 'AFNetworking', '2.0' // 只使用2.0版本
pod 'AFNetworking', '> 2.0' // 使用高于2.0的版本
pod 'AFNetworking', '>= 2.0' // 使用大于或等于2.0的版本
pod 'AFNetworking', '< 2.0' // 使用小于2.0的版本
pod 'AFNetworking', '<= 2.0' // 使用小于或等于2.0的版本
// 0.1.1、0.1.2、0.1.3、...、0.2
pod 'AFNetworking', '~> 0.1.1' // 使用大于等于0.1.1但小于0.2的版本
// 0.1、0.2、0.3、...、1.0
pod 'AFNetworking', '~> 0.1' // 使用大于等于0.1但小于1.0的版本
- 把项目中的Podfile改为
'>= 2.5.1'
or ~> 2.5.1
pod 'Bugly', '>= 2.5.1'
// 或者
pod 'Bugly', '~> 2.5.1'
# 依赖SDWebImage
s.subspec "Core" do |core|
core.source_files = "YBImageBrowser/**/*.{h,m}"
core.dependency 'SDWebImage', '>= 5.0.0'
end
# 不依赖SDWebImage
s.subspec "NOSD" do |core|
core.source_files = "YBImageBrowser/**/*.{h,m}"
core.exclude_files = "YBImageBrowser/WebImageMediator/YBIBDefaultWebImageMediator.{h,m}"
end
参考资料