Skip to content

Commit 733b3ee

Browse files
committed
Allow workspace to specify custom app plist values.
1 parent ddfbc01 commit 733b3ee

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 52;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -1470,6 +1470,7 @@
14701470
C1004E342981F77B00B8CF94 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
14711471
C1004E352981F77B00B8CF94 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
14721472
C101947127DD473C004E7EB8 /* MockKitUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MockKitUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1473+
C1092BFD29F8116700AE3D1C /* apply-info-customizations.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "apply-info-customizations.sh"; sourceTree = "<group>"; };
14731474
C10B28451EA9BA5E006EA1FC /* far_future_high_bg_forecast.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = far_future_high_bg_forecast.json; sourceTree = "<group>"; };
14741475
C11613482983096D00777E7C /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/InfoPlist.strings; sourceTree = "<group>"; };
14751476
C116134B2983096D00777E7C /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -2897,6 +2898,7 @@
28972898
C18A491522FCC22900FDA733 /* copy-plugins.sh */,
28982899
C18A491322FCC22900FDA733 /* make_scenario.py */,
28992900
C1E9CB5A295101570022387B /* install-scenarios.sh */,
2901+
C1092BFD29F8116700AE3D1C /* apply-info-customizations.sh */,
29002902
);
29012903
path = Scripts;
29022904
sourceTree = "<group>";
@@ -3123,6 +3125,7 @@
31233125
C113F4472951352C00758735 /* Install Scenarios */,
31243126
C16DA84322E8E5FF008624C2 /* Install Plugins */,
31253127
C1D19800232CFA2A0096D646 /* Capture Build Details */,
3128+
C1092BFE29F88F0600AE3D1C /* Apply Info Customizations */,
31263129
4F70C1EC1DE8DCA8006380B7 /* Embed App Extensions */,
31273130
);
31283131
buildRules = (
@@ -3659,6 +3662,26 @@
36593662
/* End PBXResourcesBuildPhase section */
36603663

36613664
/* Begin PBXShellScriptBuildPhase section */
3665+
C1092BFE29F88F0600AE3D1C /* Apply Info Customizations */ = {
3666+
isa = PBXShellScriptBuildPhase;
3667+
alwaysOutOfDate = 1;
3668+
buildActionMask = 2147483647;
3669+
files = (
3670+
);
3671+
inputFileListPaths = (
3672+
);
3673+
inputPaths = (
3674+
"$(SRCROOT)/../InfoCustomizations",
3675+
);
3676+
name = "Apply Info Customizations";
3677+
outputFileListPaths = (
3678+
);
3679+
outputPaths = (
3680+
);
3681+
runOnlyForDeploymentPostprocessing = 0;
3682+
shellPath = /bin/sh;
3683+
shellScript = "\"${SRCROOT}/Scripts/apply-info-customizations.sh\"\n";
3684+
};
36623685
C113F4472951352C00758735 /* Install Scenarios */ = {
36633686
isa = PBXShellScriptBuildPhase;
36643687
buildActionMask = 2147483647;
@@ -3715,6 +3738,7 @@
37153738
};
37163739
C1D19800232CFA2A0096D646 /* Capture Build Details */ = {
37173740
isa = PBXShellScriptBuildPhase;
3741+
alwaysOutOfDate = 1;
37183742
buildActionMask = 2147483647;
37193743
files = (
37203744
);

Scripts/apply-info-customizations.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh -e
2+
3+
# apply-info-customizations.sh
4+
# Loop
5+
#
6+
# Created by Pete Schwamb on 4/25/23.
7+
# Copyright © 2023 LoopKit Authors. All rights reserved.
8+
9+
10+
SCRIPT="$(basename "${0}")"
11+
SCRIPT_DIRECTORY="$(dirname "${0}")"
12+
13+
error() {
14+
echo "ERROR: ${*}" >&2
15+
echo "Usage: ${SCRIPT} [-i|--info-plist-path info-plist-path]" >&2
16+
echo "Parameters:" >&2
17+
echo " -i|--info-plist-path <info-plist-path> path to the Info.plist file to modify; optional, defaults to \${BUILT_PRODUCTS_DIR}/\${INFOPLIST_PATH}" >&2
18+
exit 1
19+
}
20+
21+
warn() {
22+
echo "WARN: ${*}" >&2
23+
}
24+
25+
info() {
26+
echo "INFO: ${*}" >&2
27+
}
28+
29+
info_plist_path="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
30+
while [[ $# -gt 0 ]]
31+
do
32+
case $1 in
33+
-i|--info-plist-path)
34+
info_plist_path="${2}"
35+
shift 2
36+
;;
37+
esac
38+
done
39+
40+
if [ ${#} -ne 0 ]; then
41+
error "Unexpected arguments: ${*}"
42+
fi
43+
44+
if [ "${info_plist_path}" == "/" -o ! -e "${info_plist_path}" ]; then
45+
error "Must provide valid --info-plist-path, or have valid \${BUILT_PRODUCTS_DIR} and \${INFOPLIST_PATH} set."
46+
fi
47+
48+
info "Applying info.plist customizations from ../InfoCustomizations.txt"
49+
50+
while read -r -a words; do # iterate over lines of input
51+
set -- "${words[@]}" # update positional parameters
52+
for word; do
53+
if [[ $word = *"="* ]]; then # if a word contains an "="...
54+
key=${word%%=*}
55+
value=${word#*=}
56+
echo "Key = $key"
57+
echo "Value = $value"
58+
plutil -replace $key -string "${value}" "${info_plist_path}"
59+
fi
60+
done
61+
done <"../InfoCustomizations.txt"

0 commit comments

Comments
 (0)