I'm trying to programatically figure out the git hash of the tag/branch/commit or whatever is used for a dependency of my project in order to provide more information for debugging, provided the depenency is stored in a git repo. Any ideas? I would rather not clone the dependency again.
1 Answer 1
This will depending on how the Pod has been installed. If you've installed a Pod from an external source, such as if you use the following in your Podfile:
pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'
You can find the checkout options used within the Podfile.lock, which is a machine readable YAML file:
CHECKOUT OPTIONS:
AFNetworking:
:commit: ba7b6e541fd18bdf48da6d4845670e3e6b990637
:git: https://github.com/AFNetworking/AFNetworking.git
If instead, you are using a spec repository, you would need to consult the podspec used for the Pod, which will be found in the local checkout of the pod spec repository used (if this is the master spec repository, at ~/.cocoapods/repos/master/). The pod spec will contain the required checkout information. For example, if you are using AFNetworking 2.5.2 from the master spec repository you can find the checkout information in the necessary podspec:
$ grep -A 3 '"source"' ~/.cocoapods/repos/master/Specs/AFNetworking/2.5.2/AFNetworking.podspec.json
"source": {
"git": "https://github.com/AFNetworking/AFNetworking.git",
"tag": "2.5.2",
"submodules": true