Skip to content

Commit 74b3da4

Browse files
committed
Update build scripts
1 parent 3eb3da9 commit 74b3da4

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

ForPDA.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@
916916
B8001CC22A197F0500E7A8A8 /* Set Build Number */ = {
917917
isa = PBXShellScriptBuildPhase;
918918
alwaysOutOfDate = 1;
919-
buildActionMask = 2147483647;
919+
buildActionMask = 12;
920920
files = (
921921
);
922922
inputFileListPaths = (
@@ -930,7 +930,7 @@
930930
);
931931
runOnlyForDeploymentPostprocessing = 0;
932932
shellPath = /bin/sh;
933-
shellScript = "$SRCROOT/Scripts/set_build_number.sh\n";
933+
shellScript = "$SRCROOT/scripts/set_build_number.sh\n";
934934
};
935935
B82B2EB72A87FFE700CB067C /* Sentry */ = {
936936
isa = PBXShellScriptBuildPhase;

Scripts/set_build_number.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1+
#!/bin/bash
2+
3+
# Get the Git commit count
4+
#commitCount=$(git rev-list --count HEAD)
5+
6+
# Check if commitCount is a valid number
7+
#if [[ ! $commitCount =~ ^[0-9]+$ ]]; then
8+
# echo "Failed to get Git commit count."
9+
# exit 1
10+
#fi
11+
112
git=`sh /etc/profile; which git`
213
branchName=`"$git" rev-parse --abbrev-ref HEAD`
314
buildNumber=$(expr $(git rev-list $branchName --count) - $(git rev-list HEAD..$branchName --count))
15+
416
if [ $CONFIGURATION = "Debug" ] || [ $branchName != "main" ] && [ $branchName != "develop" ];then
5-
build=$buildNumber-$branchName
17+
build=$buildNumber-$branchName
618
else
7-
build=$buildNumber
19+
build=$buildNumber
820
fi
9-
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
10-
echo "Updated ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
11-
echo "Updated build number to $build using branch '$branchName'"
1221

13-
# 把版本号显示在 Setting Bundle
14-
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"`
15-
versionBuild="$version\($build\)"
16-
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:0:DefaultValue $versionBuild" "${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}/Settings.bundle/Root.plist"
17-
echo "Updated Settings.bundle"
22+
# Set the build number in Info.plist for the main app target
23+
mainPlistPath="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
24+
echo "Setting build number to $commitCount in $mainPlistPath"
25+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $commitCount" "$mainPlistPath"
26+
27+
# Set the build number in Info.plist for each app extension
28+
appExtensions=("OpenInAppExtension" "ShareExtension") # Add the names of your app extensions here
29+
for extension in "${appExtensions[@]}"; do
30+
extensionPlistPath="${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/PlugIns/$extension.appex/Info.plist"
31+
echo "Setting build number to $commitCount in $extensionPlistPath"
32+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $commitCount" "$extensionPlistPath"
33+
done

0 commit comments

Comments
 (0)