From c03cc0fa17eb558b6ae8a7e4db971276af50c386 Mon Sep 17 00:00:00 2001 From: Jake Fenton Date: Fri, 2 Aug 2019 09:29:12 -0400 Subject: [PATCH] check if SUBundleName is set before normalizing When changing the name of an app, there's a couple things to do in order to ensure auto-updates still work: 1. set SUBundle Name. This basically tells Sparkle "ey, expect an app of {SUBundleName}.(app|pkg) instead of the normal name." 2. set `SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME` in commonConfig.xccconfig to reset the name of the app. in (2), we always used the host's bundle name, instead of checking to see if SUBundleName was set, which means normalization doesn't work as expected during app name changes. --- Autoupdate/SUInstaller.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Autoupdate/SUInstaller.m b/Autoupdate/SUInstaller.m index bede6aa1..725c6435 100644 --- a/Autoupdate/SUInstaller.m +++ b/Autoupdate/SUInstaller.m @@ -175,8 +175,14 @@ { NSBundle *bundle = host.bundle; assert(bundle != nil); - - NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]]; + + NSString * baseBundleName = [host objectForInfoDictionaryKey:@"SUBundleName"]; + + if (baseBundleName == nil) { + baseBundleName = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey]; + } + + NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", baseBundleName, [[bundle bundlePath] pathExtension]]]; // Roundtrip string through fileSystemRepresentation to ensure it uses filesystem's Unicode normalization // rather than arbitrary Unicode form from Info.plist - #1017