-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-CFBundleVersion.sh
More file actions
executable file
·41 lines (33 loc) · 1.29 KB
/
Set-CFBundleVersion.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Set-CFBundleVersion.sh
#
# Sets the built-product's CFBundeVersion to the current working-directory revision.
#
# Install by adding a Run-Script Phase to the end of target's Build Phases with:
#
# Script: $SRCROOT/Set-CFBundleVersion.sh
# Based on dependency analysis: False
# Input Files: $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
#
# Select "Run script only when installing" to limit execution to Release/Archiving.
#
# Created by Chuck Houpt on 10/23/13.
# Copyright 2013-2024 Behavioral Cybernetics LLC. All rights reserved.
set -eux
# Only run on release builds, since debug builds are by definition based on un-commmited code changes.
#if [ $CONFIGURATION != 'Release' ] ; then exit ; fi
if [[ ! -d .git ]]
then
echo "warning: working dir not under version control, could not set version"
exit
fi
REVISION=$(git rev-list --count HEAD)
DESCRIBE=$(git describe --tags --long --always --dirty=-mutant)
# Emulate SVN by adding M if dirty
case $DESCRIBE in
*-mutant) REVISION="${REVISION}M" ;;
esac
# Modify CFBundleVersion in the product's compiled Info.plist
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string $REVISION" \
-c "Add :BCGitDescribe string $DESCRIBE" \
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH" || echo "warning: failed to setup CFBundleVersion"