构建我的Cocoapod时,是否可以指定对另一个分支的依赖关系? [英] Is there a way to specify a dependency on another branch when building my Cocoapod?

查看:624
本文介绍了构建我的Cocoapod时,是否可以指定对另一个分支的依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个Cocoapod,该Cocoapod依赖Alamofire和SwiftyJSON的不同分支(当前,当iOS 9和Xcode 7超出beta时,情况将会改变)。这是因为我的Cocoapod是用Swift 2.0编码的。更具体地说,我的pod当前依赖于 swift2-0 Alamofire分支和 xcode7 SwiftyJSON分支。

I'm trying to build a Cocoapod that (currently - this will change when iOS 9 and Xcode 7 are out of beta) depends on different branches of Alamofire and SwiftyJSON. This is because my Cocoapod was coded in Swift 2.0. To be more specific, my pod currently depends on the swift2-0 Alamofire branch and xcode7 SwiftyJSON branch.

我的Podspecs文件当前如下所示:

My Podspecs file currently looks like this:

#
# Be sure to run `pod lib lint ALSMAL.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# Any lines starting with a # are optional, but encouraged
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = "ALSMAL"
  s.version          = "2.0.0"
  s.summary          = "A Swift wrapper for the Atarashii MAL API."
  s.description      = <<-DESC
A Swift, protocol-oriented iOS framework to interact with Atarashii MAL API, an unofficial API for MyAnimeList.net.
                       DESC
  #s.homepage         = "https://github.com/AndyIbanez/ALSMAL"
  s.homepage         = "https://andyibanez.com"
  s.license          = {:type => "MIT", :file => "LICENSE"}
  s.author           = { "Andy Ibanez" => "andy@andyibanez.com" }
  s.source           = { :git => "https://AndyIbanez@bitbucket.org/AndyIbanez/alsmal.git", :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/AndyIbanezK'

  s.platform     = :ios, '9.0'
  s.requires_arc = true

  s.source_files = 'ALSMAL/*'
  s.resource_bundles = {
    'ALSMAL' => ['Pod/Assets/*.png']
  }

  s.dependency 'Alamofire'
  s.dependency 'SwiftyJSON'
end

就像您看到的那样,我在的最后两行中指定Alamofire和SwiftyJSON的依赖项结束

Like you can see, I am specifying the dependencies for Alamofire and SwiftyJSON in the last two lines before end.

我在另一个StackOverflow答案中读到,我无法在Podspec中为依赖项指定分支,因此应该在我的依赖项中指定它们改为使用Podfile。我是这样做的:

I read in another StackOverflow answer that I cannot specify the branch for my dependencies in the Podspec, so I should specify them in my Podfile instead. I did that:

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!

link_with 'ALSMAL', 'ALSMALTests'

target 'ALSMAL' do
   pod 'Alamofire', :git => "https://github.com/Alamofire/Alamofire.git", :branch => "swift-2.0"
   pod 'SwiftyJSON', :git => "https://github.com/SwiftyJSON/SwiftyJSON.git", :branch => "xcode7"
end

target 'ALSMALTests' do
    pod 'Alamofire', :git => "https://github.com/Alamofire/Alamofire.git", :branch => "swift-2.0"
    pod 'SwiftyJSON', :git => "https://github.com/SwiftyJSON/SwiftyJSON.git", :branch => "xcode7"
end

然后,因为我的项目使用的是iOS 9 / Xcode 7技术,我将Xcode的命令行工具更改为使用Xcode 7 beta(Xcode>首选项>位置>将命令行工具设置为Xcode 7),并尝试将其替换。失败:

Then, because my project is using iOS 9/Xcode 7 technologies, I changed the command line tools for Xcode to use Xcode 7 beta (Xcode > Preferences > Locations > set "Command Line Tools" to Xcode 7) and tried linting it. It fails:

 - ERROR |  Alamofire/Source/Request.swift:76:30: error: '#' has been removed from Swift; double up 'user user' to make the argument label the same as the parameter name

相同错误更多,但所有错误都与从Swift 1.0 / 1.2到Swift 2.0的更改有关。

(It throws many more errors, but all of them have to do with things that changed from Swift 1.0/1.2 to Swift 2.0).

当然,这仅意味着Cocoapods正在下载是Alamofire依赖项的官方分支,因为Swift 2.0有效删除了语法,该语法用于创建具有相同名称的函数参数标签和变量。 swift2-0 分支解决了这个问题。

Of course, this can only mean that Cocoapods is downloading the official branch for the Alamofire dependency, because Swift 2.0 effectively removed the # syntax that was used to create a function parameter label and variable with the same name. The swift2-0 branch fixes this.

如果我运行单元测试,它们都可以编译并运行良好,所以有些事情使Cocoapods使用了我的依赖项的主分支版本,而不是我在Podfile中明确定义的版本。

If I run my unit tests, they all compile and run fine, so something is making Cocoapods use the master branches versions of my dependencies instead of the ones I explicitly define in my Podfile.

有什么方法可以为我设置不同的分支依赖项我的豆荚?这只是临时使用,因为我想开始构建我的iOS 9应用并在实际情况下测试我的Pod。一旦Xcode 7退出测试版,我用于我的Pod的分支极有可能会与各自的主节点合并,并且我将不必寻找解决方法来使它们再正常工作。

Is there any way I can set different branches dependencies for my pods? This will only be used temporarily, as I want to start building my iOS 9 app and test my pod in a real case. As soon as Xcode 7 is out of beta, the the branches I'm using for my pod will most likely be merged with their respective masters, and I won't have to find workarounds to make them work anymore.

推荐答案

我在 Cocoapods存储库,其中一位贡献者回答了我的问题。

I asked in the Cocoapods Repository and one of the contributors answered my question.

Linting(因此尝试上载Pod)在您的Podspec而不是Podfile上运行,

Linting (and therefore, trying to upload your pod) runs on your Podspec, not Podfile, and there is no way to specify a different branch in the Podspec.


不,只能在Podfile中设置未发布的依赖项。

No, non-released dependencies can only be set in the Podfile.

因此,我想做的是不幸的是。

What I want to do is, therefore, sadly not possible.

这篇关于构建我的Cocoapod时,是否可以指定对另一个分支的依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆