ios Pod 规范中的 Cocoapods 依赖项不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16905112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:47:53  来源:igfitidea点击:

Cocoapods dependency in pod spec not working

iosxcodecocoapods

提问by LunaCodeGirl

I'm getting a syntax error with this spec file:

我收到此规范文件的语法错误:

Pod::Spec.new do |s|

s.name         = "BSImageLoader"

s.version      = "0.1.3"

s.summary      = "The image loading framework for PicPoc"

s.homepage     = "https://bitbucket.org/boolalsofware/bsimageloader"

s.license      = 'MIT'

s.author       = { "Spencer Comerford" => "[email protected]" }

s.source       = { :git => "[email protected]:boolalsofware/bsimageloader.git", :tag => "0.1.3" }

s.source_files = 'Classes/*.{h,m}', 'Classes/PublicHeaders/*'

s.public_header_files = 'Classes/PublicHeaders/*.h'

s.dependency = 'BSTiledImageView', :git => '[email protected]:boolalsofware/bstiledimageview.git'

s.frameworks = 'QuartzCore', 'AssetsLibrary', 'UIKit'

s.requires_arc = true

end

The problem is with the dependency which points at a bitbucket repo. I have gotten this to work with local dependencies, but for some reason with a git repo it isn't working. Thanks for any help!

问题在于指向 bitbucket 存储库的依赖项。我已经让它与本地依赖项一起工作,但由于某种原因,git repo 无法正常工作。谢谢你的帮助!

采纳答案by Fabio

The dependencydirective of the podspec DSL supports only the name of the dependency and any optional version requirement. The :gitoption is not supported. You might use it in your Podfile or you might want to use a custom private repo in addition to the master repo.

dependencypodspec DSL的指令仅支持依赖项的名称和任何可选的版本要求。:git不支持该选项。您可能会在 Podfile 中使用它,或者除了主存储库之外,您可能还想使用自定义私有存储库。

回答by Roman B.

I've faced the same issue and found that there is another way to solve this problem in old manner(thanks to @eliperkins).

我遇到了同样的问题,发现有另一种方法可以用旧的方式解决这个问题(感谢@eliperkins)。

Lets say you have a main project Downloader, which uses smaller project Player, which depends on micro project FFMpegPlayer. So what you want is to have a dependency in your Player.podspec, that would look like this:

假设您有一个主项目Downloader,它使用较小的项目Player,这取决于微型项目FFMpegPlayer。所以你想要的是在你的 中有一个依赖Player.podspec,它看起来像这样:

s.dependency = 'FFMpegPlayer', :git => '...FFMpegPlayer.git' or 
s.dependency = 'FFMpegPlayer', :local => '../FFMpegPlayer'
s.dependency = 'FFMpegPlayer', :path => '../FFMpegPlayer'
s.dependency = 'FFMpegPlayer', :podspec => '../FFMpegPlayer/FFMpegPlayer.podspec'

But all that won't workwith the latest version of Pods and it turns out :localwas working as a side effect up to v0.17.1.

但所有这些都不适用于最新版本的 Pods,结果证明它:localv0.17.1.

From now, you can specify clean dependency in Player.podspec:

从现在开始,您可以在Player.podspec以下位置指定干净的依赖项:

s.dependency = 'FFMpegPlayer' (its ok if that spec does not exist in public)

In the Podfileof Downloader(main project) you just have to specify FFMpegPlayerbeforePlayerpod:

Podfileof Downloader(主项目)中,您只需FFMpegPlayerPlayerpod之前指定:

pod 'FFMpegPlayer', :path => '../FFMpegPlayer' (micro project)
pod 'Player', :path => '../Player' (small project which depends on FFMpegPlayer)

So, basically, all your subpods are now listed in main Podfile, that guarantees no conflicts between pods versions.

所以,基本上,你所有的 subpods 现在都列在主 Podfile 中,这保证了 pods 版本之间没有冲突。