From 8de8db001ea3c781f5e2b1c9abe851209dd8c08a Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 16 Sep 2024 17:03:59 -0700 Subject: [PATCH] Fix shared classes being defined both in unit tests and Sparkle (#2629) For the unit tests, we will rename the classes so they don't conflict. --- Autoupdate/SUCodeSigningVerifier.h | 6 +++++- Sparkle.xcodeproj/project.pbxproj | 2 -- Sparkle/SPUSkippedUpdate.h | 10 +++++++--- Sparkle/SUAppcastDriver.h | 6 +++++- Sparkle/SUFileManager.h | 10 +++++++--- Sparkle/SUHost.h | 6 +++++- Sparkle/SUSignatures.h | 13 ++++++++++--- 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Autoupdate/SUCodeSigningVerifier.h b/Autoupdate/SUCodeSigningVerifier.h index 2615c0bbe3..285fe60146 100644 --- a/Autoupdate/SUCodeSigningVerifier.h +++ b/Autoupdate/SUCodeSigningVerifier.h @@ -14,8 +14,12 @@ NS_ASSUME_NONNULL_BEGIN #ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS +#define SUCodeSigningVerifierDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUCodeSigningVerifierDefinitionAttribute __attribute__((objc_runtime_name("SUTestCodeSigningVerifier"))) #endif + +SUCodeSigningVerifierDefinitionAttribute @interface SUCodeSigningVerifier : NSObject + (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError **)error; diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 04afdb88b1..c217828c66 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -173,7 +173,6 @@ 722545B626805FF80036465C /* testappcast_info_updates.xml in Resources */ = {isa = PBXBuildFile; fileRef = 722545B526805FF80036465C /* testappcast_info_updates.xml */; }; 72266A872946359600645376 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */; }; 72266A88294635BA00645376 /* SUAppcastDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767C91C9B707000A07552 /* SUAppcastDriver.m */; }; - 72266A89294636FB00645376 /* SUStandardVersionComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */; }; 72266A8A2946493C00645376 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5991D3D8A5A00D1BF90 /* SUCodeSigningVerifier.m */; }; 72266A8B29464CEA00645376 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; 72266A8C29464D0200645376 /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = EA1E286D22B665E8004AA304 /* SUSignatures.m */; }; @@ -3386,7 +3385,6 @@ 72266A8C29464D0200645376 /* SUSignatures.m in Sources */, 72266A8B29464CEA00645376 /* SUHost.m in Sources */, 72266A8A2946493C00645376 /* SUCodeSigningVerifier.m in Sources */, - 72266A89294636FB00645376 /* SUStandardVersionComparator.m in Sources */, 72266A88294635BA00645376 /* SUAppcastDriver.m in Sources */, 72266A872946359600645376 /* SUFileManager.m in Sources */, 725EE488277D398100D820CE /* SPUDeltaArchive.m in Sources */, diff --git a/Sparkle/SPUSkippedUpdate.h b/Sparkle/SPUSkippedUpdate.h index 319de05de0..fe4df1d8db 100644 --- a/Sparkle/SPUSkippedUpdate.h +++ b/Sparkle/SPUSkippedUpdate.h @@ -12,15 +12,19 @@ NS_ASSUME_NONNULL_BEGIN @class SUHost, SUAppcastItem; +#ifndef BUILDING_SPARKLE_TESTS +#define SPUSkippedUpdateDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SPUSkippedUpdateDefinitionAttribute __attribute__((objc_runtime_name("SPUTestSkippedUpdate"))) +#endif + /* A skipped update tracks an optional minor version and an optional major version the user may skip. The minor and major versions are independent versions, so the user can choose to skip at most two separate versions. The intent is when the user is faced with a major upgrade, they can skip a major version. Otherwise they can choose to skip a minor version. */ -#ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS -#endif +SPUSkippedUpdateDefinitionAttribute @interface SPUSkippedUpdate : NSObject + (nullable SPUSkippedUpdate *)skippedUpdateForHost:(SUHost *)host; diff --git a/Sparkle/SUAppcastDriver.h b/Sparkle/SUAppcastDriver.h index 4830babeaf..5f033a7bc5 100644 --- a/Sparkle/SUAppcastDriver.h +++ b/Sparkle/SUAppcastDriver.h @@ -23,8 +23,12 @@ NS_ASSUME_NONNULL_BEGIN @end #ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS +#define SUAppcastDriverDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUAppcastDriverDefinitionAttribute __attribute__((objc_runtime_name("SUTestAppcastDriver"))) #endif + +SUAppcastDriverDefinitionAttribute @interface SUAppcastDriver : NSObject - (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(nullable id )delegate; diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index a81e8a2fc8..34e33afb48 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -11,14 +11,18 @@ NS_ASSUME_NONNULL_BEGIN +#ifndef BUILDING_SPARKLE_TESTS +#define SUFileManagerDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUFileManagerDefinitionAttribute __attribute__((objc_runtime_name("SUTestFileManager"))) +#endif + /** * A class used for performing file operations more suitable than NSFileManager for performing installation work. * All operations on this class may be used on thread other than the main thread. * This class provides just basic file operations and stays away from including much application-level logic. */ -#ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS -#endif +SUFileManagerDefinitionAttribute @interface SUFileManager : NSObject /** diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index f377d4f359..b4203256d2 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -12,8 +12,12 @@ NS_ASSUME_NONNULL_BEGIN @class SUPublicKeys; #ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS +#define SUHostDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUHostDefinitionAttribute __attribute__((objc_runtime_name("SUTestHost"))) #endif + +SUHostDefinitionAttribute @interface SUHost : NSObject @property (nonatomic, readonly) NSBundle *bundle; diff --git a/Sparkle/SUSignatures.h b/Sparkle/SUSignatures.h index e95e9b9885..e2b6030295 100644 --- a/Sparkle/SUSignatures.h +++ b/Sparkle/SUSignatures.h @@ -23,8 +23,12 @@ typedef NS_ENUM(uint8_t, SUSigningInputStatus) { }; #ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS +#define SUSignaturesDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUSignaturesDefinitionAttribute __attribute__((objc_runtime_name("SUTestSignatures"))) #endif + +SUSignaturesDefinitionAttribute @interface SUSignatures : NSObject #if SPARKLE_BUILD_LEGACY_DSA_SUPPORT @property (nonatomic, readonly, nullable) NSData *dsaSignature; @@ -41,10 +45,13 @@ SPU_OBJC_DIRECT_MEMBERS ; @end - #ifndef BUILDING_SPARKLE_TESTS -SPU_OBJC_DIRECT_MEMBERS +#define SUPublicKeysDefinitionAttribute SPU_OBJC_DIRECT_MEMBERS +#else +#define SUPublicKeysDefinitionAttribute __attribute__((objc_runtime_name("SUTestPublicKeys"))) #endif + +SUPublicKeysDefinitionAttribute @interface SUPublicKeys : NSObject @property (nonatomic, readonly, nullable) NSString *dsaPubKey;