首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在构建我的Cocoapod时,是否有一种方法可以指定对另一个分支的依赖?

在构建我的Cocoapod时,是否有一种方法可以指定对另一个分支的依赖?
EN

Stack Overflow用户
提问于 2015-07-24 20:06:43
回答 1查看 2.5K关注 0票数 3

我正在尝试构建一个Cocoapod,它依赖于Alamofire和SwiftyJSON的不同分支(目前--这将在iOS 9和Xcode 7脱离beta版时发生变化)。这是因为我的Cocoapod是在SWIFT2.0中编码的。更具体地说,我的吊舱目前依赖于swift2-0阿拉莫火分支和xcode7 SwiftyJSON分支。

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

代码语言:javascript
复制
#
# 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中指定它们。我做到了:

代码语言:javascript
复制
# 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),并尝试将其链接起来。它失败了:

代码语言:javascript
复制
 - 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退出测试版,我所使用的分支很可能会与它们各自的主程序合并,我将不再需要找到解决办法来使它们工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-25 20:42:48

我在Cocoapods储存库上问,其中一位投稿人回答了我的问题。

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

不,非释放依赖项只能在Podfile中设置。

因此,令人遗憾的是,我想做的是不可能做到。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31618936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档