PromiseKit pod 安装正确,但导入 PromiseKit returns 错误?

PromiseKit pod installed correctly, but import PromiseKit returns error?

我正在使用 swift 在 Xcode 8.2.1 上开发一个应用程序 3. 我有一些异步任务需要按适当的顺序排列,所以我决定使用 PromiseKit这个目的。我将一个 podfile 添加到我的项目目录并修改然后使用 pod install (通过 cocoapods)安装它。安装工作正常,因为我的命令行给了我这条成功消息:

(顺便说一下,这是 podfile 文本):

我将框架添加到项目的链接框架和库中,如下所示:

完成所有这些后,我希望能够在 viewController 的顶部使用 import PromiseKit 来访问框架库中的函数。但是,输入 import PromiseKit 给了我以下错误:

有人知道问题出在哪里吗?

安装 pod 后,您需要打开 .xcworkspace 文件而不是 .xcodeproject。此外,由于您已经安装了 PromiseKit 的 pod,因此无需再次 link 框架。只需在 xcode 中打开 .xcworkspace 即可导入 PromiseKit。

原来这个问题是因为使用了错误版本的 PromiseKit。我是 运行 pod install 没有定义 PromiseKit 应该是什么版本,希望这种歧义允许安装选择最新版本。 (此外,最初指定版本,如网站上所建议的那样:

swift_version = "3.0"
pod "PromiseKit", "~> 4.0"

会 return 一个我无法访问 4.0 的错误)。这个错误是:

` 'PromiseKit (~>4.0)' required by 'Podfile' 
None of your spec sources contain a spec satisfying the dependency:...

原来这是整体问题(我需要使用 4.0 规范)。为了摆脱这个错误,我 运行 以下命令:

pod repo remove master
pod setup
pod install #in the project directory... after modifying the podfile to the code
#written above... ie. including the '"~> 4.0"'

不过,回购和设置需要一些时间。

在我的例子中 iOS 部署目标对于 Pod 目标来说已经过时了。

要解决,select Pods 在项目导航中,select Pods 目标,并在构建设置中更新 [iOS 部署目标] .