From 76897896d2ae90c9f05b255cd0dfa9e8b9fe68e5 Mon Sep 17 00:00:00 2001 From: Yuval Shavit Date: Sat, 25 May 2024 14:21:27 -0400 Subject: [PATCH 1/3] add logging to set_plist_build --- buildscripts/set_plist_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/buildscripts/set_plist_build.sh b/buildscripts/set_plist_build.sh index b3c58cda..e0bf26d8 100755 --- a/buildscripts/set_plist_build.sh +++ b/buildscripts/set_plist_build.sh @@ -1,4 +1,5 @@ #!/bin/bash -e +set -x sha="$(git log -n 1 '--pretty=format:%h')" if [[ $(git status -s | wc -c) -ne 0 ]]; then From ff94a7094d19514f8f7353426bf9a82306950b9e Mon Sep 17 00:00:00 2001 From: Yuval Shavit Date: Sat, 25 May 2024 14:29:33 -0400 Subject: [PATCH 2/3] exit if fail --- buildscripts/set_plist_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/buildscripts/set_plist_build.sh b/buildscripts/set_plist_build.sh index e0bf26d8..356d8c6f 100755 --- a/buildscripts/set_plist_build.sh +++ b/buildscripts/set_plist_build.sh @@ -25,5 +25,6 @@ for plist in "$info_plist" "$target_plist" "$dsym_plist"; do fi else echo "Missing plist: $plist" + exit 1 fi done From b823d456df2a1ec8c1b12e3277bfb2828d49de86 Mon Sep 17 00:00:00 2001 From: Yuval Shavit Date: Sat, 25 May 2024 17:00:29 -0400 Subject: [PATCH 3/3] fix how we generate the Info.plist full version Do it via preprocessor. That preprocessor is itself generated, so do that as a separate target so that it runs before the preprocessor gets used. --- buildscripts/create_infoplist_preprocessor.sh | 13 ++ buildscripts/infoplist-preprocess/.gitignore | 1 + buildscripts/infoplist-preprocess/README.md | 2 + .../infoplist-preprocess/fixed/sparkle.h | 1 + buildscripts/set_plist_build.sh | 30 ----- whatdid.xcodeproj/project.pbxproj | 120 ++++++++++++++---- whatdid/Info.plist | 4 +- 7 files changed, 112 insertions(+), 59 deletions(-) create mode 100755 buildscripts/create_infoplist_preprocessor.sh create mode 100644 buildscripts/infoplist-preprocess/.gitignore create mode 100644 buildscripts/infoplist-preprocess/README.md create mode 100644 buildscripts/infoplist-preprocess/fixed/sparkle.h delete mode 100755 buildscripts/set_plist_build.sh diff --git a/buildscripts/create_infoplist_preprocessor.sh b/buildscripts/create_infoplist_preprocessor.sh new file mode 100755 index 00000000..d95f9429 --- /dev/null +++ b/buildscripts/create_infoplist_preprocessor.sh @@ -0,0 +1,13 @@ +#!/bin/bash -euo pipefail + +sha="$(git log -n 1 '--pretty=format:%h')" +if [[ $(git status -s | wc -c) -ne 0 ]]; then + sha="${sha}.dirty" +fi + +preprocess_dir=infoplist-preprocess +compiled_headers="$preprocess_dir/compiled.h" + +cat "$preprocess_dir/fixed/"*.h > "$compiled_headers" + +printf '#define FULL_BUILD_VERSION %s\n' "$(/bin/date -u '+%Y.%m%d.%H%M%S')" >> "$compiled_headers" diff --git a/buildscripts/infoplist-preprocess/.gitignore b/buildscripts/infoplist-preprocess/.gitignore new file mode 100644 index 00000000..18cf9ee6 --- /dev/null +++ b/buildscripts/infoplist-preprocess/.gitignore @@ -0,0 +1 @@ +compiled.h diff --git a/buildscripts/infoplist-preprocess/README.md b/buildscripts/infoplist-preprocess/README.md new file mode 100644 index 00000000..51986029 --- /dev/null +++ b/buildscripts/infoplist-preprocess/README.md @@ -0,0 +1,2 @@ +- fixed.h is checked in +- compiled.h is generated from `fixed/*.h plus other stuff by `buildscripts/create_infoplist_preprocessor.sh` diff --git a/buildscripts/infoplist-preprocess/fixed/sparkle.h b/buildscripts/infoplist-preprocess/fixed/sparkle.h new file mode 100644 index 00000000..b96eb8bc --- /dev/null +++ b/buildscripts/infoplist-preprocess/fixed/sparkle.h @@ -0,0 +1 @@ +#define SPARKLE_FEED_URL "https://whatdid.yuvalshavit.com/appcast/appcast.xml" diff --git a/buildscripts/set_plist_build.sh b/buildscripts/set_plist_build.sh deleted file mode 100755 index 356d8c6f..00000000 --- a/buildscripts/set_plist_build.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -e -set -x - -sha="$(git log -n 1 '--pretty=format:%h')" -if [[ $(git status -s | wc -c) -ne 0 ]]; then - sha="${sha}.dirty" -fi -now="$(/bin/date -u '+%Y.%m%d.%H%M%S')" - -info_plist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH" -target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" -dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" -for plist in "$info_plist" "$target_plist" "$dsym_plist"; do - if [ -f "$plist" ]; then - echo "Found plist: $plist" - old_sha=$(/usr/libexec/PlistBuddy -c "Print :ComYuvalShavitWtfdidVersion" "$plist" || echo '') - if [[ "$old_sha" != "$sha" ]] ; then - echo "Updating sha to $sha (was: $old_sha)" - /usr/libexec/PlistBuddy -c "Delete :ComYuvalShavitWtfdidVersion" "$plist" || true - /usr/libexec/PlistBuddy -c "Add :ComYuvalShavitWtfdidVersion string $sha" "$plist" - # Also set the version string - /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $now" "$plist" - else - echo "Found old sha ($sha), leaving untouched." - fi - else - echo "Missing plist: $plist" - exit 1 - fi -done diff --git a/whatdid.xcodeproj/project.pbxproj b/whatdid.xcodeproj/project.pbxproj index 001f8a5e..752e2147 100644 --- a/whatdid.xcodeproj/project.pbxproj +++ b/whatdid.xcodeproj/project.pbxproj @@ -6,6 +6,20 @@ objectVersion = 54; objects = { +/* Begin PBXAggregateTarget section */ + 60D5F41C2C0286430017D139 /* infoplist-preprocess-generator */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 60D5F41D2C0286430017D139 /* Build configuration list for PBXAggregateTarget "infoplist-preprocess-generator" */; + buildPhases = ( + 60D5F4212C02865D0017D139 /* ShellScript */, + ); + dependencies = ( + ); + name = "infoplist-preprocess-generator"; + productName = "infoplist-preprocess-generator"; + }; +/* End PBXAggregateTarget section */ + /* Begin PBXBuildFile section */ 6E01204F389CB80FC8CD75ED /* EditEntriesDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E012F97EBB4C11F269A1939 /* EditEntriesDataSource.swift */; }; 6E012216A8475ABF72DEBC69 /* EntriesTreeControllerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E012ED45DEC1A299BFA43AB /* EntriesTreeControllerTest.swift */; }; @@ -291,6 +305,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 60D5F4222C02868C0017D139 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7E8C04D223714F0700A0C3A6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60D5F41C2C0286430017D139; + remoteInfo = "infoplist-preprocess-generator"; + }; + 60D5F4242C0286D20017D139 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7E8C04D223714F0700A0C3A6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 60D5F41C2C0286430017D139; + remoteInfo = "infoplist-preprocess-generator"; + }; 7E8C04EB23714F0800A0C3A6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 7E8C04D223714F0700A0C3A6 /* Project object */; @@ -1010,12 +1038,12 @@ 7E8C04D623714F0700A0C3A6 /* Sources */, 7E8C04D723714F0700A0C3A6 /* Frameworks */, 7E8C04D823714F0700A0C3A6 /* Resources */, - 7E1C2F4F24CE33780070D8CD /* Set gitsha in Info.plist */, 7E6FF1C2252D73EA0071E58C /* CopyFiles */, ); buildRules = ( ); dependencies = ( + 60D5F4232C02868C0017D139 /* PBXTargetDependency */, ); name = whatdid; packageProductDependencies = ( @@ -1069,12 +1097,12 @@ 7EF30DD42AC2B4920097FA24 /* Sources */, 7EF30E2F2AC2B4920097FA24 /* Frameworks */, 7EF30E332AC2B4920097FA24 /* Resources */, - 7EF30E3F2AC2B4920097FA24 /* Set gitsha in Info.plist */, 7EF30E402AC2B4920097FA24 /* CopyFiles */, ); buildRules = ( ); dependencies = ( + 60D5F4252C0286D20017D139 /* PBXTargetDependency */, ); name = "whatdid-app-store"; packageProductDependencies = ( @@ -1094,6 +1122,9 @@ LastUpgradeCheck = 1320; ORGANIZATIONNAME = "Yuval Shavit"; TargetAttributes = { + 60D5F41C2C0286430017D139 = { + CreatedOnToolsVersion = 15.4; + }; 7E6FF19B252D71060071E58C = { CreatedOnToolsVersion = 12.0.1; }; @@ -1132,6 +1163,7 @@ 7E8C04E923714F0800A0C3A6 /* whatdidTests */, 7E8C04F423714F0800A0C3A6 /* whatdidUITests */, 7E6FF19B252D71060071E58C /* WhatdidLauncher */, + 60D5F41C2C0286430017D139 /* infoplist-preprocess-generator */, ); }; /* End PBXProject section */ @@ -1203,7 +1235,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 7E1C2F4F24CE33780070D8CD /* Set gitsha in Info.plist */ = { + 60D5F4212C02865D0017D139 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; buildActionMask = 2147483647; @@ -1213,33 +1245,14 @@ ); inputPaths = ( ); - name = "Set gitsha in Info.plist"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "set -euo pipefail\n$SRCROOT/buildscripts/set_plist_build.sh\n"; - }; - 7EF30E3F2AC2B4920097FA24 /* Set gitsha in Info.plist */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 12; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Set gitsha in Info.plist"; outputFileListPaths = ( ); outputPaths = ( + "$(SRCROOT)/buildscripts/infoplist-preprocess/compiled.h", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -euo pipefail\n$SRCROOT/buildscripts/set_plist_build.sh\n"; + shellScript = "set -euo pipefail\ncd \"$SRCROOT/buildscripts/\"\n./create_infoplist_preprocessor.sh\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -1528,6 +1541,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 60D5F4232C02868C0017D139 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 60D5F41C2C0286430017D139 /* infoplist-preprocess-generator */; + targetProxy = 60D5F4222C02868C0017D139 /* PBXContainerItemProxy */; + }; + 60D5F4252C0286D20017D139 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 60D5F41C2C0286430017D139 /* infoplist-preprocess-generator */; + targetProxy = 60D5F4242C0286D20017D139 /* PBXContainerItemProxy */; + }; 7E8C04EC23714F0800A0C3A6 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 7E8C04D923714F0700A0C3A6 /* whatdid */; @@ -1552,6 +1575,33 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 60D5F41E2C0286430017D139 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = CUJYAXXM6G; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 60D5F41F2C0286430017D139 /* UI Test */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = CUJYAXXM6G; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "UI Test"; + }; + 60D5F4202C0286430017D139 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = CUJYAXXM6G; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; 7E6FF1A7252D71080071E58C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2004,12 +2054,14 @@ COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = whatdid/Info.plist; + INFOPLIST_PREFIX_HEADER = "$(PROJECT_DIR)/buildscripts/infoplist-preprocess/compiled.h"; + INFOPLIST_PREPROCESS = YES; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.2.1; + MARKETING_VERSION = 0.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.yuvalshavit.whatdid; PRODUCT_NAME = Whatdid; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2027,12 +2079,14 @@ COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = whatdid/Info.plist; + INFOPLIST_PREFIX_HEADER = "$(PROJECT_DIR)/buildscripts/infoplist-preprocess/compiled.h"; + INFOPLIST_PREPROCESS = YES; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.2.1; + MARKETING_VERSION = 0.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.yuvalshavit.whatdid; PRODUCT_NAME = Whatdid; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2051,12 +2105,14 @@ DEVELOPMENT_TEAM = CUJYAXXM6G; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = whatdid/Info.plist; + INFOPLIST_PREFIX_HEADER = "$(PROJECT_DIR)/buildscripts/infoplist-preprocess/compiled.h"; + INFOPLIST_PREPROCESS = YES; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 0.2.1; + MARKETING_VERSION = 0.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.yuvalshavit.whatdid; PRODUCT_NAME = Whatdid; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2067,6 +2123,16 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 60D5F41D2C0286430017D139 /* Build configuration list for PBXAggregateTarget "infoplist-preprocess-generator" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 60D5F41E2C0286430017D139 /* Debug */, + 60D5F41F2C0286430017D139 /* UI Test */, + 60D5F4202C0286430017D139 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 7E6FF1AA252D71080071E58C /* Build configuration list for PBXNativeTarget "WhatdidLauncher" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/whatdid/Info.plist b/whatdid/Info.plist index f81f1423..c4e5afee 100644 --- a/whatdid/Info.plist +++ b/whatdid/Info.plist @@ -21,7 +21,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 1 + FULL_BUILD_VERSION LSApplicationCategoryType public.app-category.productivity LSMinimumSystemVersion @@ -41,7 +41,7 @@ SUEnableInstallerLauncherService SUFeedURL - https://whatdid.yuvalshavit.com/appcast/appcast.xml + SPARKLE_FEED_URL SUPublicEDKey +c3D0qE8WwVHoLX6rl2fTqniphIs/5s4UPW4D7w+KxQ=