Swift 具有 Cocoapods 依赖项的项目

Swift project with Cocoapods dependencies

我有以下 cocoapods Podfile

platform :ios, '8.0'

use_frameworks!

target 'Foo' do
        pod "SwiftyJSON", '~> 2.2.0'
        pod "Locksmith"
        pod "GoogleMaps"
        pod "RealmSwift"
end

target 'FooTests' do

end

我也在使用 cocoapods 0.37.2。出于某种原因,当我尝试 运行 该应用程序时,它会抱怨以下错误,而我已经明确指定我的项目需要 SwiftyJSON 2.2.0 或更高版本:

 Reason: Incompatible library version: Foo requires version 2.0.0 or later, but SwiftyJSON provides version 1.0.0

我已验证 SwiftyJSON 没有其他依赖项(使用 cocoapods-dependencies):

$pod dependencies

Dependencies
---
- GoogleMaps (1.10.1)
- Locksmith (1.2.2)
- Realm (0.93.2):
  - Realm/Headers (= 0.93.2)
- Realm/Headers (0.93.2)
- RealmSwift (0.93.2):
  - Realm (= 0.93.2)
- SwiftyJSON (2.2.0)

如你所见,没有人在拉SwiftyJSON 1.0.0。顺便说一下,我使用 cocoapods 0.37.2 的原因是因为当我尝试使用 0.38.1 时出现了这个错误:https://github.com/CocoaPods/CocoaPods/issues/3890

我在这里遗漏了什么(关于 SwiftyJSON 版本不匹配)吗?我试过清理项目、重做 pod 安装等,但没有任何运气..

提前致谢!

对我来说(似乎对你来说),以下方法有效:

  1. 从 podfile 中删除有罪的 pods(在我的例子中,AFNetworkingAFNetworkActivityLogger
  2. pod install消灭他们
  3. 升级(如果您使用的是 0.38.1,则降级)到 cocoapods 0.38.0
  4. 添加 pods 返回 & pod install

现在我回来了……我相信 0.38.1 是让我陷入困境的罪魁祸首。