有没有办法在构build我的Cocoapod时指定另一个分支的依赖关系?

我试图build立一个Cocoapod(目前 – 这将改变当iOS 9和Xcode 7超出testing版)取决于Alamofire和SwiftyJSON的不同分支。 这是因为我的Cocoapod编码在Swift 2.0中。 更具体地说,我的pod目前依赖于swift2-0 Alamofire分支和xcode7 SwiftyJSON分支。

我的Podspecs文件目前看起来像这样:

 # # 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的依赖关系。

我读了另一个StackOverflow的答案,我不能在Podspec中指定我的依赖关系的分支,所以我应该在我的Podfile中指定它们。 我这样做了:

 # 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> Preferences> Locations> set“Command Line Tools”to Xcode 7)并尝试使用它。 它失败:

  - 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的东西有关)。

当然,这只能意味着Cocoapods正在下载Alamofire依赖关系的官方分支,因为Swift 2.0有效地删除了用于创build具有相同名称的函数参数标签和variables的#语法。 swift2-0分支修复了这个问题。

如果我运行我的unit testing,他们都编译和运行良好,所以一些正在使Cocoapods使用我的依赖的主分支版本,而不是我在我的Podfile中明确定义的。

有没有什么办法可以为我的豆荚设置不同的分支依赖关系? 这只会暂时使用,因为我想开始构build我的iOS 9应用程序并在真实情况下testing我的窗格。 只要Xcode 7不在testing版中,我用于我的Pod的分支将很可能会与其各自的主人合并,我不必find解决方法,使他们的工作了。

我问在Cocoapods知识库和其中一个贡献者回答我的问题。

Linting(因此,试图上传您的窗格)运行在您的Podspec,而不是Podfile,并且没有办法在Podspec中指定不同的分支。

不,没有释放的依赖关系只能在Podfile中设置。

所以我想要做的是,可悲的是不可能的。