首页 > 解决方案 > 如何在 podfile 中获取 git 分支?

问题描述

所以我在一个使用 cocoapods 的 iOS 项目中工作。我有一些通过 cocoapods 添加的自定义库。例如:

pod 'MyLibrary', :git => 'git@git.mydomain.com:pods/mylibrary-pod.git', :tag => '1.1'

我想根据我当前的 git 分支更改 MyLibrary 的版本。像这样的东西:

if DEVELOP_BRANCH
  pod 'MyLibrary', :git => 'git@git. mydomain.com:pods/mylibrary-develop-pod.git', :tag => '1.1.7'
else if MASTER_BRANCH
  pod 'MyLibrary', :git => 'git@git. mydomain.com:pods/mylibrary-pod.git', :tag => '1.1' 

但我不知道是否有任何方法可以从我的本地存储库中检查当前的 git 分支。有人知道这是否可能以及一种方法吗?

标签: iosgitcocoapodspodfile

解决方案


在这里,您可以在库 repo 的根目录中查看来自 podspec 的指南。 喜欢用 Almofire

pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'

希望这会有所帮助,谢谢


推荐阅读