2

So I'm working in an iOS project using cocoapods. I have some custom libraries that are added via 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. 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. Does someone knows if it's possible and a way to do it?

Marc Estrada
  • 1,657
  • 10
  • 20
  • You won't get around doing a pod install after switching your branch if you do it that way. But you could script that locally. Maybe a git submodule is the better option while developing? Or a build config? But that depends on why you have to have certain things in a separate branch.... – MartinM Jun 24 '19 at 10:29
  • It won't be any problem doing a pod install after changing the branch. I need to separate the repos or at least the tags because the development of that library usually is more advanced on develop branch than the master one. And for testing purposes I use the develop branch and to publish the library I use the master branch. But you gave me an idea, using targets in podfile. I'll try it. – Marc Estrada Jun 24 '19 at 10:36

1 Answers1

0

Here you can see Guideline for From a podspec in the root of a library repo. like to use Almofire

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

Hope this will help, Thanks

Aleem
  • 3,173
  • 5
  • 33
  • 71
  • Thanks, I've seen this post, but it talks about choose a specific branch, commit or tag from the remote repo where the lib is hosted. But I want to check my current local branch. I mean, I want to check if I'm in the develop branch or the master branch, in the local repo I'm working with. – Marc Estrada Jun 24 '19 at 10:30