问题描述
我正在尝试将以下依赖项添加到我的 Podspec 中
I am trying to add the following dependency to my Podspec
s.dependency 'Apollo/WebSocket', :git => 'https://github.com/apollographql/apollo-ios'
当我尝试运行 pod lib lint MyPodName.podspec
时,我会在终端中看到以下内容:
Here's what I get in my Terminal whenever I try to run pod lib lint MyPodName.podspec
:
- ERROR | spec: The specification defined in `MyPodName.podspec` could not be loaded.
[!] Invalid `MyPodName.podspec` file: [!] Unsupported version requirements.
# from <PathToMyPodspec>/MyPodName.podspec:36
# -------------------------------------------
#
> s.dependency 'Apollo/WebSocket', :git => 'https://github.com/apollographql/apollo-ios'
#
# -------------------------------------------
我已经成功地将它用作我的一个 iOS 项目中的 Pod.但是现在我自己创建了一个 pod,我很难理解我应该怎么做才能让它工作.
I have successfully used it as a Pod in one of my iOS projects. But now that I am creating a pod myself, I am struggling to understand what I should do to make it work.
提前谢谢你!
推荐答案
解决了!
事实证明,项目的 Podfile 文档在所有这一切中都扮演着重要的角色.我在所述项目的 /Example
文件夹中找到了它.我所做的是:
It turns out that the Podfile document of the project plays a major role in all of this. I found it inside the /Example
folder of said project. What I've done is:
use_frameworks!
source = 'https://github.com/apollographql/apollo-ios'
source = 'https://github.com/apollographql/apollo-ios'
target 'MyPodName_Example' do
pod 'Apollo'
pod 'Apollo/WebSocket'
pod 'MyPodName', :path => '../'
target 'MyPodName_Tests' do
inherit! :search_paths
end
end
(我不太确定我是否一定需要这两行 source
行,但它确实像这样工作)
(I am not quite sure if I necessarily need both of the source
lines but it does work like this)
然后我在 /Example
目录上运行 pod install
.
Then I ran pod install
on the /Example
directory.
之后,我返回到我的 MyPodName.podspec
文件并编辑了依赖项,如下所示:
After that I returned back to my MyPodName.podspec
file and edited dependencies to look like this:
s.dependency 'Apollo'
s.dependency 'Apollo/WebSocket'
然后我在根目录(我的 .podspec
文件所在的位置)上运行 pod lib lint MyPodName.podspec
,这次它成功了.
Then I ran pod lib lint MyPodName.podspec
on the root directory (where my .podspec
file is) and this time it succeeded.
注意:
- 我需要
Apollo
和Apollo/WebSocket
依赖项. - 我还没有推送我的 Pod,不能保证所有这些都是 100% 正确的
- 我是 CocoaPods 的新手,所以这可能不是解决问题的最佳方案.
这篇关于将带有源的 Pod 依赖项添加到 .podspec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!