diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 796914e4..42b4a218 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -156,7 +156,7 @@ 724BB3B11D3484B2005D534A /* SPUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SPUSystemAuthorization.m */; }; 724BB3B21D34862A005D534A /* SPUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SPUSystemAuthorization.m */; }; 724BB3B71D35ABA8005D534A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; - 725602D51C83551C00DAA70E /* SPUApplicationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 725602D31C83551C00DAA70E /* SPUApplicationInfo.h */; }; + 725602D51C83551C00DAA70E /* SPUApplicationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 725602D31C83551C00DAA70E /* SPUApplicationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; 725602D61C83551C00DAA70E /* SPUApplicationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 725602D41C83551C00DAA70E /* SPUApplicationInfo.m */; }; 725CB9571C7120410064365A /* SPUUserDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 725CB9561C7120410064365A /* SPUUserDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; 725CB95A1C7121830064365A /* SPUStandardUserDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 725CB9581C7121830064365A /* SPUStandardUserDriver.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1853,6 +1853,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 725602D51C83551C00DAA70E /* SPUApplicationInfo.h in Headers */, 72F9EC441D5E9ED8004AC8B6 /* SPUDownloadData.h in Headers */, 725F977B1C8A896F00265BE4 /* SPUUserDriverCoreComponent.h in Headers */, 72F9EC481D5EA904004AC8B6 /* SPUUpdaterDelegate.h in Headers */, @@ -1885,7 +1886,6 @@ 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */, 14652F8419A978C200959E44 /* SUExport.h in Headers */, 7267E5FD1D3DD1B700D1BF90 /* SUDownloadedUpdate.h in Headers */, - 725602D51C83551C00DAA70E /* SPUApplicationInfo.h in Headers */, 55C14F06136EF6DB00649790 /* SULog.h in Headers */, 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */, 72B767E61C9CFD7200A07552 /* SUAutomaticUpdateDriver.h in Headers */, diff --git a/Sparkle/SPUApplicationInfo.h b/Sparkle/SPUApplicationInfo.h index ff39e8ef..ff0aa388 100644 --- a/Sparkle/SPUApplicationInfo.h +++ b/Sparkle/SPUApplicationInfo.h @@ -7,10 +7,11 @@ // #import +#import "SUExport.h" NS_ASSUME_NONNULL_BEGIN -@interface SPUApplicationInfo : NSObject +SU_EXPORT @interface SPUApplicationInfo : NSObject + (BOOL)isBackgroundApplication:(NSApplication *)application; diff --git a/Sparkle/Sparkle.h b/Sparkle/Sparkle.h index 0a3ea00d..94042e92 100644 --- a/Sparkle/Sparkle.h +++ b/Sparkle/Sparkle.h @@ -26,6 +26,7 @@ #import "SPUUserDriver.h" #import "SPUStandardUserDriver.h" #import "SPUStandardUserDriverDelegate.h" +#import "SPUApplicationInfo.h" #import "SPUUserDriverCoreComponent.h" #import "SPUDownloadData.h" diff --git a/TestApplication/SUPopUpTitlebarUserDriver.h b/TestApplication/SUPopUpTitlebarUserDriver.h index 8549c17e..30d6cac0 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.h +++ b/TestApplication/SUPopUpTitlebarUserDriver.h @@ -13,6 +13,6 @@ @interface SUPopUpTitlebarUserDriver : NSObject -- (instancetype)initWithWindow:(NSWindow *)window delegate:(id)delegate; +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window delegate:(id)delegate; @end diff --git a/TestApplication/SUPopUpTitlebarUserDriver.m b/TestApplication/SUPopUpTitlebarUserDriver.m index dc6f6c70..5f16f842 100644 --- a/TestApplication/SUPopUpTitlebarUserDriver.m +++ b/TestApplication/SUPopUpTitlebarUserDriver.m @@ -14,6 +14,7 @@ @interface SUPopUpTitlebarUserDriver() +@property (nonatomic, readonly) NSBundle *hostBundle; @property (nonatomic, readonly) NSWindow *window; @property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent; @property (nonatomic) NSTitlebarAccessoryViewController *accessoryViewController; @@ -28,6 +29,7 @@ @implementation SUPopUpTitlebarUserDriver @synthesize delegate = _delegate; +@synthesize hostBundle = _hostBundle; @synthesize window = _window; @synthesize coreComponent = _coreComponent; @synthesize accessoryViewController = _accessoryViewController; @@ -37,10 +39,11 @@ @synthesize expectedContentLength = _expectedContentLength; @synthesize contentLengthDownloaded = _contentLengthDownloaded; -- (instancetype)initWithWindow:(NSWindow *)window delegate:(id)delegate +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window delegate:(id)delegate { self = [super init]; if (self != nil) { + _hostBundle = hostBundle; _window = window; _delegate = delegate; _coreComponent = [[SPUUserDriverCoreComponent alloc] initWithDelegate:delegate]; @@ -316,7 +319,8 @@ // In case our termination request fails or is delayed [self removeUpdateButton]; - [[NSApplication sharedApplication] terminate:nil]; + NSRunningApplication *runningApplication = [SPUApplicationInfo runningApplicationWithBundle:self.hostBundle]; + [runningApplication terminate]; }); } diff --git a/TestApplication/SUUpdateSettingsWindowController.m b/TestApplication/SUUpdateSettingsWindowController.m index 1be70752..d0d8c35d 100644 --- a/TestApplication/SUUpdateSettingsWindowController.m +++ b/TestApplication/SUUpdateSettingsWindowController.m @@ -29,18 +29,18 @@ - (void)windowDidLoad { - NSBundle *mainBundle = [NSBundle mainBundle]; + NSBundle *hostBundle = [NSBundle mainBundle]; // If the user is holding down command, we use the popup title user driver instead id userDriver; if (([NSEvent modifierFlags] & NSCommandKeyMask) != 0) { - userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithWindow:self.window delegate:nil]; + userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithHostBundle:hostBundle window:self.window delegate:nil]; } else { - userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:mainBundle delegate:nil]; + userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:nil]; } self.userDriver = userDriver; - self.updater = [[SPUUpdater alloc] initWithHostBundle:mainBundle userDriver:userDriver delegate:nil]; + self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:nil]; NSError *updaterError = nil; if (![self.updater startUpdater:&updaterError]) {