From ea149426435ace68a2c2f42f75612624b304dc45 Mon Sep 17 00:00:00 2001 From: Mayur Pawashe Date: Mon, 19 Jul 2021 08:07:06 -0700 Subject: [PATCH] Fix project warnings (#1893) Port changes from 2.x to fix some project warnings in master branch: * Copy phase strip warning on binaries when building Distribution * No app category set on Autoupdate * -Watimport-in-framework-header warnings * id messaging warnings * -Wcompletion-handler warnings * Some deprecated base64 APIs * Explicit SDK and adhoc signing identity * Upgrade project last update check * Don't use manual ordering for building targets and set Sparkle.framework as dependency to XCFrameworks aggregate target * Silenced WKWebView deprecation warning * Fixed no output node warning in git config script by removing input node like in 2.x --- Configurations/ConfigCommon.xcconfig | 2 ++ Configurations/ConfigCommonRelease.xcconfig | 1 + Sparkle.xcodeproj/project.pbxproj | 27 +++++++++++++----- .../xcschemes/Distribution.xcscheme | 28 ++++++++----------- .../xcschemes/Sparkle Test App.xcscheme | 2 +- .../xcshareddata/xcschemes/Sparkle.xcscheme | 26 +++++++---------- .../xcshareddata/xcschemes/UITests.xcscheme | 8 +----- .../xcschemes/XCFramework.xcscheme | 2 +- .../xcschemes/generate_appcast.xcscheme | 12 ++------ Sparkle/Autoupdate/Autoupdate-Info.plist | 2 ++ Sparkle/SUAppcastItem.h | 3 ++ Sparkle/SUBinaryDeltaCreate.m | 26 ++++++++--------- Sparkle/SUSignatures.m | 2 +- Sparkle/SUUnarchiverNotifier.m | 2 ++ Sparkle/SUUpdatePermissionPrompt.m | 9 ++++++ Sparkle/SUWKWebView.m | 3 ++ TestApplication/SUTestApplicationDelegate.m | 2 +- 17 files changed, 84 insertions(+), 73 deletions(-) diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 9307c4ca..88f28504 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -32,6 +32,8 @@ PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034id GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\" +CODE_SIGN_IDENTITY = - +SDKROOT = macosx ENABLE_HARDENED_RUNTIME = YES; CLANG_ENABLE_OBJC_ARC = YES GCC_ENABLE_PASCAL_STRINGS = NO diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index 99b4777e..7b16ab2e 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -15,3 +15,4 @@ GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEAD_CODE_STRIPPING = YES GCC_TREAT_WARNINGS_AS_ERRORS = NO GCC_WARN_UNINITIALIZED_AUTOS = YES +COPY_PHASE_STRIP = NO diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 769d821e..11d147f9 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 895C5DBD24D75F590058A82D /* ShellScript */, ); dependencies = ( + 72DA9D4726A0273500B12BB2 /* PBXTargetDependency */, ); name = XCFramework; productName = Sparkle.xcframework; @@ -544,6 +545,13 @@ remoteGlobalIDString = 61B5F90109C4CEE200B25A18; remoteInfo = "Sparkle Test App"; }; + 72DA9D4626A0273500B12BB2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8DC2EF4F0486A6940098B216; + remoteInfo = Sparkle; + }; 895C5DBE24D764DD0058A82D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -2109,23 +2117,25 @@ attributes = { CLASSPREFIX = SU; LastSwiftUpdateCheck = 1000; - LastUpgradeCheck = 1230; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "Sparkle Project"; TargetAttributes = { 5A5ADED6214EDE4900DF0099 = { CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1300; ProvisioningStyle = Automatic; }; 5AA96C541E0AE0DB00CA4346 = { CreatedOnToolsVersion = 8.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1300; ProvisioningStyle = Automatic; }; 5AB8F19E214DA72000A1187F = { + LastSwiftMigration = 1300; ProvisioningStyle = Automatic; }; 612279D80DB5470200AB99EA = { - LastSwiftMigration = 0900; + LastSwiftMigration = 1300; TestTargetID = 8DC2EF4F0486A6940098B216; }; 722954B31D04ADAF00ECF9CA = { @@ -2298,14 +2308,13 @@ files = ( ); inputPaths = ( - $BUILT_PRODUCTS_DIR/$INFOPLIST_PATH, ); name = "Run Script: Set Git Version Info"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\""; + shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\"\n"; showEnvVarsInLog = 0; }; 6131B1910DDCDE32005215F0 /* Run Script: Set Git Version Info */ = { @@ -2314,14 +2323,13 @@ files = ( ); inputPaths = ( - $BUILT_PRODUCTS_DIR/$INFOPLIST_PATH, ); name = "Run Script: Set Git Version Info"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\""; + shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\"\n"; showEnvVarsInLog = 0; }; 895C5DBD24D75F590058A82D /* ShellScript */ = { @@ -2721,6 +2729,11 @@ target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */; targetProxy = 726B2B621C645FC900388755 /* PBXContainerItemProxy */; }; + 72DA9D4726A0273500B12BB2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8DC2EF4F0486A6940098B216 /* Sparkle */; + targetProxy = 72DA9D4626A0273500B12BB2 /* PBXContainerItemProxy */; + }; 895C5DBF24D764DD0058A82D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 895C5DB924D75F370058A82D /* XCFramework */; diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index 04505d17..5adf9f02 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -1,9 +1,9 @@ + + + + @@ -40,23 +48,11 @@ - - - - - - - - + + + + @@ -40,23 +48,11 @@ - - - - - - - - - - - - - - - - + + - - MainMenu NSPrincipalClass NSApplication + LSApplicationCategoryType + public.app-category.utilities CFBundleIconFile ${ASSETCATALOG_COMPILER_APPICON_NAME}.icns diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index c424bb87..77bcb1f8 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -10,6 +10,9 @@ #define SUAPPCASTITEM_H #if __has_feature(modules) +#if __has_warning("-Watimport-in-framework-header") +#pragma clang diagnostic ignored "-Watimport-in-framework-header" +#endif @import Foundation; #else #import diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 44e2d501..53b5771f 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -165,7 +165,7 @@ static NSString *temporaryPatchFile(NSString *patchFile) static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary *newInfo) { - unsigned long long fileSize = [newInfo[INFO_SIZE_KEY] unsignedLongLongValue]; + unsigned long long fileSize = [(NSNumber *)newInfo[INFO_SIZE_KEY] unsignedLongLongValue]; if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) { return YES; } @@ -174,11 +174,11 @@ static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary return YES; } - if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) { + if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) { return YES; } - if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) { + if ([(NSNumber *)originalInfo[INFO_HASH_KEY] isEqual:(NSNumber *)newInfo[INFO_HASH_KEY]]) { // this is possible if just the permissions have changed return YES; } @@ -192,7 +192,7 @@ static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *ne return NO; } - if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) { + if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) { return YES; } @@ -205,11 +205,11 @@ static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newIn return NO; } - if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) { + if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) { return NO; } - if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) { + if (![(NSNumber *)originalInfo[INFO_HASH_KEY] isEqual:(NSNumber *)newInfo[INFO_HASH_KEY]]) { return NO; } @@ -222,11 +222,11 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne return NO; } - if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) { + if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) { return NO; } - if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) { + if ([(NSNumber *)originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) { return NO; } @@ -379,7 +379,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF // We should also not allow files with code signed extended attributes since Apple doesn't recommend inserting these // inside an application, and since we don't preserve extended attribitutes anyway - mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue]; + mode_t permissions = [(NSNumber *)info[INFO_PERMISSIONS_KEY] unsignedShortValue]; if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) { permissions = 0755; if (verbose) { @@ -414,7 +414,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF } else { newTreeState[key] = info; - if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) { + if (oldInfo && [(NSNumber *)oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [(NSNumber *)info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) { NSArray *parentPathComponents = key.pathComponents; for (NSString *childPath in originalTreeState) { @@ -489,7 +489,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF for (NSString *key in keys) { id value = [newTreeState valueForKey:key]; - if ([value isEqual:[NSNull null]]) { + if ([(NSObject *)value isEqual:[NSNull null]]) { xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1); assert(newFile); xar_prop_set(newFile, DELETE_KEY, "true"); @@ -507,10 +507,10 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF if (shouldChangePermissions(originalInfo, newInfo)) { xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1); assert(newFile); - xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]); + xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]); if (verbose) { - fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]); + fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [(NSNumber *)originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]); } } } else { diff --git a/Sparkle/SUSignatures.m b/Sparkle/SUSignatures.m index 8e07d7e7..f478e54b 100644 --- a/Sparkle/SUSignatures.m +++ b/Sparkle/SUSignatures.m @@ -19,7 +19,7 @@ static NSData *decode(NSString *str) { } NSString *stripped = [str stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]; - return [[NSData alloc] initWithBase64Encoding:stripped]; + return [[NSData alloc] initWithBase64EncodedString:stripped options:0]; } - (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519 diff --git a/Sparkle/SUUnarchiverNotifier.m b/Sparkle/SUUnarchiverNotifier.m index 643f0eb9..4fd5e37d 100644 --- a/Sparkle/SUUnarchiverNotifier.m +++ b/Sparkle/SUUnarchiverNotifier.m @@ -31,6 +31,8 @@ if (self != nil) { _completionBlock = [completionBlock copy]; _progressBlock = [progressBlock copy]; + } else { + assert(false); } return self; } diff --git a/Sparkle/SUUpdatePermissionPrompt.m b/Sparkle/SUUpdatePermissionPrompt.m index 41131643..21978d0f 100644 --- a/Sparkle/SUUpdatePermissionPrompt.m +++ b/Sparkle/SUUpdatePermissionPrompt.m @@ -67,6 +67,10 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE systemProfileInformationArray = profile; [self setShouldCascadeWindows:NO]; } + else + { + assert(false); + } return self; } @@ -79,7 +83,12 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; } +#pragma clang diagnostic push +#if __has_warning("-Wcompletion-handler") +#pragma clang diagnostic ignored "-Wcompletion-handler" +#endif if (![NSApp modalWindow]) { // do not prompt if there is is another modal window on screen +#pragma clang diagnostic pop SUUpdatePermissionPrompt *prompt = [(SUUpdatePermissionPrompt *)[[self class] alloc] initWithHost:host systemProfile:profile reply:reply]; NSWindow *window = [prompt window]; if (window) { diff --git a/Sparkle/SUWKWebView.m b/Sparkle/SUWKWebView.m index 331f53f4..6b0f0510 100644 --- a/Sparkle/SUWKWebView.m +++ b/Sparkle/SUWKWebView.m @@ -77,7 +77,10 @@ static WKUserScript *_userScriptWithInjectedStyleSource(NSString *styleSource) // that involves implementing a delegate method that is only available on macOS 11.. to get it properly working. // To simplify things, just rely on deprecated property for now. // Future reader: if you change how JS is disabled, please be sure to test that JS code is properly disabled in HTML release notes. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" configuration.preferences.javaScriptEnabled = javaScriptEnabled; +#pragma clang diagnostic pop configuration.preferences.javaScriptCanOpenWindowsAutomatically = NO; NSError *colorStyleContentsError = nil; diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 2240980e..94bd1b70 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -133,7 +133,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; ed25519_sign(signature, archive.bytes, archive.length, public_key, self_sign_demo_only_insecure_hack); - NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64Encoding]; + NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64EncodedStringWithOptions:0]; // Obtain the file attributes to get the file size of our update later NSError *fileAttributesError = nil;