#!/bin/bash ## IMPORTANT ## # Add the following files to Input Files configuraiton of the build phase # $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH) # $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist update_plist_key() { local plist=$1 local key=$2 local value=$3 if /usr/libexec/PlistBuddy -c "Print :$key" "$plist" > /dev/null 2>&1; then /usr/libexec/PlistBuddy -c "Set :$key string $value" "$plist" else /usr/libexec/PlistBuddy -c "Add :$key string $value" "$plist" fi } git=$(sh /etc/profile; which git) commit_hash=$("$git" rev-parse --short HEAD) build_time=$(date "+%-d/%b/%Y") target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" for plist in "$target_plist" "$dsym_plist"; do if [ -f "$plist" ]; then echo "updating $plist" update_plist_key "$plist" "BuildTime" "$build_time" update_plist_key "$plist" "CommitHash" "$commit_hash" fi done