From 45345c0a443e3e9dd46bdb55a292014aecf764d4 Mon Sep 17 00:00:00 2001 From: Dmytro Tretiakov Date: Wed, 26 Aug 2015 12:07:42 +0300 Subject: [PATCH] Corrected test app updates check when it's signed. --- Configurations/ConfigTestApp.xcconfig | 1 + TestApplication/SUTestApplicationDelegate.m | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Configurations/ConfigTestApp.xcconfig b/Configurations/ConfigTestApp.xcconfig index f34249fc..357674fb 100644 --- a/Configurations/ConfigTestApp.xcconfig +++ b/Configurations/ConfigTestApp.xcconfig @@ -5,3 +5,4 @@ WRAPPER_EXTENSION = app ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) CODE_SIGN_IDENTITY="$(CODE_SIGN_IDENTITY)" diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 8b0f1d55..b8728729 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -9,6 +9,13 @@ #import "SUTestApplicationDelegate.h" #import "SUUpdateSettingsWindowController.h" +#define MACROSTRING(x) #x +#define NSSTRING_MACRO(x) @MACROSTRING(x) + +#ifndef CODE_SIGN_IDENTITY +#define CODE_SIGN_IDENTITY +#endif + @interface SUTestApplicationDelegate () @property (nonatomic) SUUpdateSettingsWindowController *updateSettingsWindowController; @@ -22,6 +29,7 @@ @synthesize serverTask = _serverTask; static NSString * const UPDATED_VERSION = @"2.0"; +static NSString * const CODE_SIGN_ID = NSSTRING_MACRO(CODE_SIGN_IDENTITY); - (void)applicationDidFinishLaunching:(NSNotification * __unused)notification { @@ -91,6 +99,17 @@ static NSString * const UPDATED_VERSION = @"2.0"; BOOL wroteInfoFile = [infoDictionary writeToURL:infoURL atomically:NO]; assert(wroteInfoFile); + if ([CODE_SIGN_ID length]) + { + NSTask *codesignTask = [[NSTask alloc] init]; + codesignTask.launchPath = @"/usr/bin/codesign"; + codesignTask.arguments = @[@"-s", CODE_SIGN_ID, @"-fv", destinationBundleURL.path]; + [codesignTask launch]; + [codesignTask waitUntilExit]; + + assert(codesignTask.terminationStatus == 0); + } + // Change current working directory so web server knows where to list files BOOL changedCurrentWorkingDirectory = [fileManager changeCurrentDirectoryPath:serverDirectoryURL.path]; assert(changedCurrentWorkingDirectory);