From 22e32a2304133eda09e13638c4dd87239a3d91b9 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 17 Apr 2016 03:17:34 -0400 Subject: [PATCH] Add codesign script and disable more signing for release modes We have a custom codesign-after-copy script because Xcode's code sign on copy feature is bad when it comes to frameworks including signable tools. In release build configurations, nothing we build uses an ad-hoc code signature. This is logical because ad-hoc signatures are only meant to be used for testing purposes. --- Configurations/ConfigTestApp.xcconfig | 3 +- Configurations/ConfigTestAppDebug.xcconfig | 4 +++ Configurations/ConfigTestAppHelper.xcconfig | 3 +- .../ConfigTestAppHelperDebug.xcconfig | 4 +++ Sparkle.xcodeproj/project.pbxproj | 12 ++++--- bin/codesign_sparkle.py | 35 +++++++++++++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 Configurations/ConfigTestAppDebug.xcconfig create mode 100644 Configurations/ConfigTestAppHelperDebug.xcconfig create mode 100644 bin/codesign_sparkle.py diff --git a/Configurations/ConfigTestApp.xcconfig b/Configurations/ConfigTestApp.xcconfig index 8c5f7b08..df4e968e 100644 --- a/Configurations/ConfigTestApp.xcconfig +++ b/Configurations/ConfigTestApp.xcconfig @@ -1,4 +1,4 @@ -// Test Application only +// Test Application INFOPLIST_FILE = TestApplication/TestApplication-Info.plist WRAPPER_EXTENSION = app @@ -6,4 +6,3 @@ ASSETCATALOG_COMPILER_APPICON_NAME = $(SPARKLE_ICON_NAME) LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp CODE_SIGN_ENTITLEMENTS = TestApplication/Sparkle-Test-App.entitlements -CODE_SIGN_IDENTITY = - \ No newline at end of file diff --git a/Configurations/ConfigTestAppDebug.xcconfig b/Configurations/ConfigTestAppDebug.xcconfig new file mode 100644 index 00000000..5b764768 --- /dev/null +++ b/Configurations/ConfigTestAppDebug.xcconfig @@ -0,0 +1,4 @@ +// Test Application Debug +#include "ConfigTestApp.xcconfig" + +CODE_SIGN_IDENTITY = - diff --git a/Configurations/ConfigTestAppHelper.xcconfig b/Configurations/ConfigTestAppHelper.xcconfig index 33a8ac58..c7fbd95e 100644 --- a/Configurations/ConfigTestAppHelper.xcconfig +++ b/Configurations/ConfigTestAppHelper.xcconfig @@ -1,7 +1,6 @@ -// Test Application Helper only +// Test Application Helper INFOPLIST_FILE = TestAppHelper/Info.plist WRAPPER_EXTENSION = xpc LD_RUNPATH_SEARCH_PATHS = @executable_path/../../../../Frameworks PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.TestAppHelper -CODE_SIGN_IDENTITY = - diff --git a/Configurations/ConfigTestAppHelperDebug.xcconfig b/Configurations/ConfigTestAppHelperDebug.xcconfig new file mode 100644 index 00000000..00c4854d --- /dev/null +++ b/Configurations/ConfigTestAppHelperDebug.xcconfig @@ -0,0 +1,4 @@ +// Test Application Helper Debug +#include "ConfigTestAppHelper.xcconfig" + +CODE_SIGN_IDENTITY = - diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index e006a5a1..5fef56da 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -903,6 +903,8 @@ 72F94ED61CC344A7002DEE68 /* ConfigUpdateDownloaderDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUpdateDownloaderDebug.xcconfig; sourceTree = ""; }; 72F94ED71CC344E4002DEE68 /* ConfigAppcastDownloaderDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigAppcastDownloaderDebug.xcconfig; sourceTree = ""; }; 72F94ED81CC34529002DEE68 /* ConfigRemoteMessagePortDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigRemoteMessagePortDebug.xcconfig; sourceTree = ""; }; + 72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppDebug.xcconfig; sourceTree = ""; }; + 72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigTestAppHelperDebug.xcconfig; sourceTree = ""; }; 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGuidedPackageInstaller.h; sourceTree = ""; }; 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = ""; }; @@ -1619,7 +1621,9 @@ FA1941CE0D94A70100DD942E /* ConfigRelaunch.xcconfig */, 721C24571CB754E8005440CB /* ConfigInstallerProgress.xcconfig */, FA1941CD0D94A70100DD942E /* ConfigTestApp.xcconfig */, + 72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */, 726E4A281C86CAB500C57C6A /* ConfigTestAppHelper.xcconfig */, + 72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */, FA3AAF3B1050B273004B3130 /* ConfigUnitTest.xcconfig */, 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */, 729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */, @@ -2896,7 +2900,7 @@ }; 149B785C1B7D398100D7D62C /* Coverage */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FA1941CD0D94A70100DD942E /* ConfigTestApp.xcconfig */; + baseConfigurationReference = 72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */; buildSettings = { }; name = Coverage; @@ -3012,7 +3016,7 @@ }; 61B5F90609C4CEE300B25A18 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FA1941CD0D94A70100DD942E /* ConfigTestApp.xcconfig */; + baseConfigurationReference = 72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */; buildSettings = { }; name = Debug; @@ -3124,14 +3128,14 @@ }; 726E4A231C86C88F00C57C6A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 726E4A281C86CAB500C57C6A /* ConfigTestAppHelper.xcconfig */; + baseConfigurationReference = 72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */; buildSettings = { }; name = Debug; }; 726E4A241C86C88F00C57C6A /* Coverage */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 726E4A281C86CAB500C57C6A /* ConfigTestAppHelper.xcconfig */; + baseConfigurationReference = 72F94EDB1CC36C6F002DEE68 /* ConfigTestAppHelperDebug.xcconfig */; buildSettings = { }; name = Coverage; diff --git a/bin/codesign_sparkle.py b/bin/codesign_sparkle.py new file mode 100644 index 00000000..cf459bb1 --- /dev/null +++ b/bin/codesign_sparkle.py @@ -0,0 +1,35 @@ +# You can run this by creating a new sh run script in your application target's build phase eg like so: +# /usr/bin/python ${SRCROOT}/codesign_sparkle.py +# +# You must also disable "Code Sign on Copy" option which Xcode defaults to having 'on' when copying Sparkle.framework into your application. +# We use this script instead because Apple's code sign on copy functionality does not work well for frameworks that include other bundles. +# Note this script is safe to run even if no code signing identity is being used (nothing would happen in this case) + +import os, sys, subprocess + +def code_sign(identity, path): + process = subprocess.Popen(["codesign", "-fs", identity, path], stdout=subprocess.PIPE) + process.communicate() + assert(process.returncode == 0) + +if __name__ == "__main__": + sparkle_path = os.path.join(os.path.join(os.environ["TARGET_BUILD_DIR"], os.environ["FRAMEWORKS_FOLDER_PATH"]), "Sparkle.framework") + + # It's ok if no code signing identity exists, that just means we won't have to do anything + try: + signing_identity = os.environ["CODE_SIGN_IDENTITY"] + except KeyError: + sys.exit(0) + + if len(signing_identity) == 0: + sys.exit(0) + + #Sign any services inside of our framework + services_directory = os.path.join(sparkle_path, "XPCServices") + for filename in os.listdir(services_directory): + if filename.endswith(".xpc"): + full_path = os.path.join(services_directory, filename) + code_sign(signing_identity, full_path) + + #Finally sign our framework + code_sign(signing_identity, sparkle_path)