我正在尝试构建一个Cocoapod,它依赖于Alamofire和SwiftyJSON的不同分支(目前--这将在iOS 9和Xcode 7脱离beta版时发生变化)。这是因为我的Cocoapod是在SWIFT2.0中编码的。更具体地说,我的吊舱目前依赖于swift2-0阿拉莫火分支和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正如您所看到的,我在SwiftyJSON之前的最后两行中指定了Alamofire和end的依赖项。
我在另一个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“到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(它会抛出更多的错误,但所有这些错误都与从SWIFT1.0/1.2到SWIFT2.0之间的变化有关)。
当然,这只能意味着Cocoapods正在下载Alamofire依赖项的官方分支,因为SWIFT2.0有效地删除了用于创建函数参数标签和同名变量的#语法。swift2-0分支修复了这个问题。
如果我运行我的单元测试,它们都会编译和运行良好,所以Cocoapods使用我的依赖项的主分支版本,而不是我在Podfile中显式定义的版本。
有任何方法可以为我的荚设置不同的分支依赖关系吗?这将只是暂时使用,因为我想开始构建我的iOS 9应用程序,并测试我的荚在一个真实的情况。一旦Xcode 7退出测试版,我所使用的分支很可能会与它们各自的主程序合并,我将不再需要找到解决办法来使它们工作。
发布于 2015-07-25 20:42:48
我在Cocoapods储存库上问,其中一位投稿人回答了我的问题。
Linting (因此,试图上传您的pod)运行在您的Podspec上,而不是Podfile上,并且无法在Podspec中指定不同的分支。
不,非释放依赖项只能在Podfile中设置。
因此,令人遗憾的是,我想做的是不可能做到。
https://stackoverflow.com/questions/31618936
复制相似问题