Skip to content

Commit 6fa8ad4

Browse files
committed
Fix Sparkle 2 build error on older Xcode / fix sign/notarize scripts
Sparkle 2: Seems like older Xcode versions (before 12.5) have problems signing frameworks that only have a Versions/B but not a Versions/A folder. Sparkle 2 moved to only having Versions/B which is causing code sign to fail on build step. Just fix this issue by disabling Sign on Copy for Sparkle.framework. We don't really need it because it already comes with an ad-hoc signature anyway, and for publish we have a custom signing script (sign-developer-id) to do manual signing. Also, fix CI to use Sparkle 2 again for old Xcode (11.7) builds to test this working. Previously we made it use Sparkle 1 because we didn't work around this issue, which was kind of a hack. For Sparkle 2, also add a `cleanup-after-build` script to remove the XPC Services folder in the framework. Sparkle dev added this to the bundle for sandboxed apps but non-sandbox apps don't really need it and it's recommended by Sparkle to remove them, so we unfortunately need to manually do it as a post-build step. Fix #1335 Signing / notarization scripts: Make sure to sign Sparkle 2 binaries in `sign-developer-id`. Also, seems like the "--deep" flag in codesign is now deprecated as of macOS 13, so just stop using it and manually sign all the relevant binaries explicitly. For notarization script, the current behavior doesn't correctly detect failure as `xcrun notarytool submit` always exits with 0 even if the submission failed. Add logic to manually query whether the submission succeeded. If failed, print out the logs for easier diagnosis, and exits with -1 so it will block progress.
1 parent d311aae commit 6fa8ad4

File tree

5 files changed

+95
-21
lines changed

5 files changed

+95
-21
lines changed

.github/workflows/ci-macvim.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,8 @@ jobs:
7878
echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET_LEGACY" >> $GITHUB_ENV
7979
echo "MACVIM_ARCHS=$MACVIM_ARCHS_LEGACY" >> $GITHUB_ENV
8080
81-
- name: Set up Sparkle 1
82-
if: matrix.legacy || !matrix.publish
83-
run: |
8481
# Use Sparkle 1 because Sparkle 2 requires newer OS version than our legacy build.
8582
# Later, we pass the --enable-sparkle_1 flag to configure to set the corresponding ifdef.
86-
#
87-
# We also do this for non-publish builds, because those are usually run on older versions
88-
# of Xcode, and they cannot handle the Sparkle 2 framework as it's built using newer Xcode.
8983
ln -fhs Sparkle_1.framework src/MacVim/Sparkle.framework
9084
9185
# Set up, install, and cache gettext library for localization.

src/MacVim/MacVim.xcodeproj/project.pbxproj

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
6666
528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
6767
52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
68-
52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
68+
52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
6969
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
7070
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
7171
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
@@ -870,6 +870,7 @@
870870
528DA6671426D456003380F1 /* Copy Scripts */,
871871
52283AB71EBA200C00A6F6B9 /* Copy mvim scripts */,
872872
90C052E1251E889500E2D81E /* Copy vimtutor */,
873+
9099B3CA2914B272005C9F32 /* Clean up build */,
873874
);
874875
buildRules = (
875876
);
@@ -1035,6 +1036,26 @@
10351036
shellScript = "BINPATH=$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/bin\nmkdir -p \"${BINPATH}\"\ncp -a \"${SRCROOT}/mvim\" \"${BINPATH}/mvim\"\nchmod 755 \"${BINPATH}/mvim\"\n(cd \"${BINPATH}\"; for f in vim vimdiff view gvim gvimdiff gview mvimdiff mview; do ln -fs mvim $f; done)\n";
10361037
showEnvVarsInLog = 0;
10371038
};
1039+
9099B3CA2914B272005C9F32 /* Clean up build */ = {
1040+
isa = PBXShellScriptBuildPhase;
1041+
alwaysOutOfDate = 1;
1042+
buildActionMask = 2147483647;
1043+
files = (
1044+
);
1045+
inputFileListPaths = (
1046+
);
1047+
inputPaths = (
1048+
);
1049+
name = "Clean up build";
1050+
outputFileListPaths = (
1051+
);
1052+
outputPaths = (
1053+
);
1054+
runOnlyForDeploymentPostprocessing = 0;
1055+
shellPath = /bin/sh;
1056+
shellScript = "./scripts/cleanup-after-build $BUILT_PRODUCTS_DIR/$WRAPPER_NAME\n";
1057+
showEnvVarsInLog = 0;
1058+
};
10381059
90BD4EF224E0E8B700BF29F2 /* Copy locale message translation files */ = {
10391060
isa = PBXShellScriptBuildPhase;
10401061
buildActionMask = 2147483647;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# Utility script to clean up after a MacVim build.
4+
5+
if [[ $# == 0 ]]; then
6+
echo "Usage: cleanup-after-build <MacVim_app>"
7+
exit -1
8+
fi
9+
10+
set -e
11+
12+
macvim_path=$1
13+
14+
sparkle_xpcservices="$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/Current/XPCServices"
15+
16+
if [ -d $sparkle_xpcservices ]; then
17+
# This only happens when building using Sparkle 2. It contains XPC Services
18+
# files which are only necessary for sandboxed apps, and not recommended
19+
# otherwise. See https://sparkle-project.org/documentation/sandboxing/.
20+
set -x
21+
rm -rf $sparkle_xpcservices
22+
fi

src/MacVim/scripts/notarize-dmg

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,38 @@ if [[ "$USE_ALTOOL" != "1" ]]; then
3030
exit -1
3131
fi
3232

33-
# Step 1: Submit app for notarization, and wait till it finishes.
34-
set -x
35-
xcrun notarytool submit ${macvim_dmg} --keychain-profile "${NOTARIZATION_KEYCHAIN_PROFILE}" --progress --wait --timeout=20m
36-
set +x
33+
# Step 1.1: Submit app for notarization, and wait till it finishes.
34+
notarize_submit_results=$(set -x; xcrun notarytool submit ${macvim_dmg} --keychain-profile "${NOTARIZATION_KEYCHAIN_PROFILE}")
35+
36+
echo $notarize_submit_results
37+
notarize_submit_uuid=$(echo $notarize_submit_results | grep "id:" | head -1 | sed -E "s/^.*id:[ ]*(.*)/\1/")
38+
39+
if [[ ${notarize_submit_uuid} == "" ]]; then
40+
echo "Failed to submit for notarization!"
41+
exit -1
42+
fi
43+
if ! [[ ${notarize_submit_uuid} =~ "^[a-f0-9\-]*$" ]]; then
44+
echo "Request UUID format error!"
45+
echo ${notarize_submit_uuid}
46+
exit -1
47+
fi
48+
49+
(set -x; xcrun notarytool wait --keychain-profile "${NOTARIZATION_KEYCHAIN_PROFILE}" --progress --timeout=20m $notarize_submit_uuid)
50+
51+
# Step 1.2: Confirm that notarization succeeded. If not, print the log. We
52+
# have to manually query instead of using return code because xcrun
53+
# notarytool always exits with 0 regardless of success.
54+
notarize_results=$(xcrun notarytool info --keychain-profile "${NOTARIZATION_KEYCHAIN_PROFILE}" $notarize_submit_uuid)
55+
notarize_status=$(echo $notarize_results | grep "status:" | sed -E "s/^.*status:[ ]*(.*)/\1/")
56+
if [[ $notarize_status == "Accepted" ]]; then
57+
printf "\n"
58+
echo "Notarization Success!\n"
59+
else
60+
printf "\n"
61+
echo "Notarization Failed!\n"
62+
xcrun notarytool log --keychain-profile "${NOTARIZATION_KEYCHAIN_PROFILE}" $notarize_submit_uuid
63+
exit -1
64+
fi
3765
else
3866
# Legacy Xcode 12 path using altool and username + app-specific password.
3967
# See: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow/notarizing_apps_when_developing_with_xcode_12_and_earlier
@@ -89,13 +117,10 @@ fi
89117

90118
# Step 2: Staple the notarization info to the DMG so that an offline user can
91119
# verify that it is notarized.
92-
set -x
93-
xcrun stapler staple ${macvim_dmg}
94-
set +x
120+
(set -x; xcrun stapler staple ${macvim_dmg})
95121

96122
# Just print out extra info for reference
97123
echo "--------------------"
98124
set -x
99125
codesign -d --verbose=2 ${macvim_dmg}
100126
spctl -a -t open --context context:primary-signature -v ${macvim_dmg}
101-
set +x

src/MacVim/scripts/sign-developer-id

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,23 @@ if [[ $macvim_path =~ dmg ]]; then
2121
set -x
2222
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path
2323
else
24-
# Sign bottom-up to make sure everything is signed. Note: --deep doesn't
25-
# catch certain edge cases like the files in Resources, hence the need to
26-
# manually sign them before signing the main app.
24+
# Sign bottom-up to make sure everything is signed in order.
25+
# Note: Not using --deep because it's been deprecated since macOS 13, and
26+
# also it doesn't catch all the binaries anyway so it's better to just be
27+
# explicit and sign everything in order to be clear what we are doing.
28+
if [ -d $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A ]; then
29+
(set -x
30+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app)
31+
fi
32+
if [ -d $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B ]; then
33+
(set -x
34+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate
35+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Updater.app)
36+
fi
2737
set -x
28-
codesign -f -s "Developer ID Application" -o runtime --deep --timestamp $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app
29-
codesign -f -s "Developer ID Application" -o runtime --deep --timestamp $macvim_path/Contents/Library/QuickLook/QLStephen.qlgenerator/Contents/MacOS/QLStephen
30-
codesign -f -s "Developer ID Application" -o runtime --deep --timestamp --entitlements $entitlements $macvim_path
38+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Frameworks/Sparkle.framework
39+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Frameworks/PSMTabBarControl.framework
40+
codesign -f -s "Developer ID Application" -o runtime --timestamp $macvim_path/Contents/Library/QuickLook/QLStephen.qlgenerator/Contents/MacOS/QLStephen
41+
codesign -f -s "Developer ID Application" -o runtime --timestamp --entitlements $entitlements $macvim_path/Contents/MacOS/Vim
42+
codesign -f -s "Developer ID Application" -o runtime --timestamp --entitlements $entitlements $macvim_path
3143
fi

0 commit comments

Comments
 (0)