How to enable git commit hash code in Xcode?

I have an application in which people can report errors directly from it, but I would like the user to be able to imagine which git hash the application was attached to. Xcode provides #define that will include this information, or should I include it in some kind of custom build script?

+5
source share
1 answer

I wrote an implementation based on the answer provided by gagarwal. I added this build script to my build steps before the compilation step:

/usr/libexec/PlistBuddy -c "Set :GIT_COMMIT_HASH `git rev-parse HEAD`" "${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}" 

In my code, I reference it by calling:

 [[NSBundle mainBundle] infoDictionary][@"GIT_COMMIT_HASH"]; 

And voila, your last hash value is available at runtime!

+10
source

Source: https://habr.com/ru/post/1205303/


All Articles