简体   繁体   English

如何在podfile中获取git branch?

[英]How to get git branch inside the podfile?

So I'm working in an iOS project using cocoapods. 所以我正在使用cocoapods在iOS项目中工作。 I have some custom libraries that are added via cocoapods. 我有一些通过cocoapods添加的自定义库。 For example: 例如:

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

I'd like to change the MyLibrary's version depending on the current git branch I am. 我想根据当前的git分支更改MyLibrary的版本。 Something like that: 像这样:

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' 

But I don't know if there is any way to check the current git branch from my local repository. 但是我不知道是否有任何方法可以从本地存储库中检查当前的git分支。 Does someone knows if it's possible and a way to do it? 有人知道这是否可行和实现的方法吗?

Here you can see Guideline for From a podspec in the root of a library repo. 在这里,您可以看到库回购根目录中的From podpo的准则 like to use Almofire 喜欢使用Almofire

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

Hope this will help, Thanks 希望这会有所帮助,谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM