From fc11629bd80e3f40253c372e4fdb8df3981e35cc Mon Sep 17 00:00:00 2001 From: Nick Cooke Date: Tue, 13 Aug 2024 15:21:04 -0400 Subject: [PATCH] [Infra] Force link remaining categories after #13435 --- .../Sources/FIRInAppMessaging.m | 18 ++++++++++++++++++ .../Runtime/FIRInAppMessaging+Bootstrap.m | 4 ++++ .../Util/NSString+FIRInterlaceStrings.m | 4 ++++ .../UIApplication+FIRForegroundWindowScene.m | 4 ++++ .../Sources/Util/UIColor+FIRIAMHexString.m | 4 ++++ .../Source/Library/FIRInstallations.m | 12 ++++++++++++ ...InstallationsItem+RegisterInstallationAPI.m | 4 ++++ FirebaseMessaging/Sources/FIRMessaging.m | 14 ++++++++++++++ .../Sources/NSDictionary+FIRMessaging.m | 4 ++++ .../Sources/NSError+FIRMessaging.m | 4 ++++ 10 files changed, 72 insertions(+) diff --git a/FirebaseInAppMessaging/Sources/FIRInAppMessaging.m b/FirebaseInAppMessaging/Sources/FIRInAppMessaging.m index d50476bc5f2..a30e2d0eb11 100644 --- a/FirebaseInAppMessaging/Sources/FIRInAppMessaging.m +++ b/FirebaseInAppMessaging/Sources/FIRInAppMessaging.m @@ -138,6 +138,24 @@ - (void)triggerEvent:(NSString *)eventName { checkAndDisplayNextContextualMessageForAnalyticsEvent:eventName]; } +#pragma mark - Force Category Linking + +extern void FIRInclude_FIRInAppMessaging_Bootstrap_Category(void); +extern void FIRInclude_UIApplication_FIRForegroundWindowScene_Category(void); +extern void FIRInclude_NSString_InterlaceStrings_Category(void); +extern void FIRInclude_UIColor_HexString_Category(void); + +/// Does nothing when called, and not meant to be called. +/// +/// This method forces the linker to include categories even if +/// users do not include the '-ObjC' linker flag in their project. ++ (void)noop { + FIRInclude_FIRInAppMessaging_Bootstrap_Category(); + FIRInclude_UIApplication_FIRForegroundWindowScene_Category(); + FIRInclude_NSString_InterlaceStrings_Category(); + FIRInclude_UIColor_HexString_Category(); +} + @end #endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION diff --git a/FirebaseInAppMessaging/Sources/Runtime/FIRInAppMessaging+Bootstrap.m b/FirebaseInAppMessaging/Sources/Runtime/FIRInAppMessaging+Bootstrap.m index aa4157de27f..9aa4aa350e7 100644 --- a/FirebaseInAppMessaging/Sources/Runtime/FIRInAppMessaging+Bootstrap.m +++ b/FirebaseInAppMessaging/Sources/Runtime/FIRInAppMessaging+Bootstrap.m @@ -137,4 +137,8 @@ + (void)exitAppWithFatalError:(NSError *)error { @end +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_FIRInAppMessaging_Bootstrap_Category(void) { +} + #endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION diff --git a/FirebaseInAppMessaging/Sources/Util/NSString+FIRInterlaceStrings.m b/FirebaseInAppMessaging/Sources/Util/NSString+FIRInterlaceStrings.m index 787da932356..a6d54afc93f 100644 --- a/FirebaseInAppMessaging/Sources/Util/NSString+FIRInterlaceStrings.m +++ b/FirebaseInAppMessaging/Sources/Util/NSString+FIRInterlaceStrings.m @@ -44,4 +44,8 @@ + (NSString *)fir_interlaceString:(NSString *)stringOne withString:(NSString *)s @end +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_NSString_InterlaceStrings_Category(void) { +} + #endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION diff --git a/FirebaseInAppMessaging/Sources/Util/UIApplication+FIRForegroundWindowScene.m b/FirebaseInAppMessaging/Sources/Util/UIApplication+FIRForegroundWindowScene.m index 1658ad41c74..af2ec1855b1 100644 --- a/FirebaseInAppMessaging/Sources/Util/UIApplication+FIRForegroundWindowScene.m +++ b/FirebaseInAppMessaging/Sources/Util/UIApplication+FIRForegroundWindowScene.m @@ -37,4 +37,8 @@ - (nullable UIWindowScene *)fir_foregroundWindowScene { @end +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_UIApplication_FIRForegroundWindowScene_Category(void) { +} + #endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION diff --git a/FirebaseInAppMessaging/Sources/Util/UIColor+FIRIAMHexString.m b/FirebaseInAppMessaging/Sources/Util/UIColor+FIRIAMHexString.m index 34c9e220e0e..8760fdd800f 100644 --- a/FirebaseInAppMessaging/Sources/Util/UIColor+FIRIAMHexString.m +++ b/FirebaseInAppMessaging/Sources/Util/UIColor+FIRIAMHexString.m @@ -41,4 +41,8 @@ + (UIColor *)firiam_colorWithHexString:(nullable NSString *)hexString { } @end +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_UIColor_HexString_Category(void) { +} + #endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION diff --git a/FirebaseInstallations/Source/Library/FIRInstallations.m b/FirebaseInstallations/Source/Library/FIRInstallations.m index d42db4bc4b7..4ee099e4cb9 100644 --- a/FirebaseInstallations/Source/Library/FIRInstallations.m +++ b/FirebaseInstallations/Source/Library/FIRInstallations.m @@ -267,6 +267,18 @@ + (BOOL)isIIDVersionCompatible { return isCompatibleVersion; } +#pragma mark - Force Category Linking + +extern void FIRInclude_FIRInstallationsItem_RegisterInstallationAPI_Category(void); + +/// Does nothing when called, and not meant to be called. +/// +/// This method forces the linker to include categories even if +/// users do not include the '-ObjC' linker flag in their project. ++ (void)noop { + FIRInclude_FIRInstallationsItem_RegisterInstallationAPI_Category(); +} + @end NS_ASSUME_NONNULL_END diff --git a/FirebaseInstallations/Source/Library/InstallationsAPI/FIRInstallationsItem+RegisterInstallationAPI.m b/FirebaseInstallations/Source/Library/InstallationsAPI/FIRInstallationsItem+RegisterInstallationAPI.m index e5c736010ed..90696f04e01 100644 --- a/FirebaseInstallations/Source/Library/InstallationsAPI/FIRInstallationsItem+RegisterInstallationAPI.m +++ b/FirebaseInstallations/Source/Library/InstallationsAPI/FIRInstallationsItem+RegisterInstallationAPI.m @@ -140,3 +140,7 @@ + (NSString *)validStringOrNilForKey:(NSString *)key fromDict:(NSDictionary *)di } @end + +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_FIRInstallationsItem_RegisterInstallationAPI_Category(void) { +} diff --git a/FirebaseMessaging/Sources/FIRMessaging.m b/FirebaseMessaging/Sources/FIRMessaging.m index a163131c613..af18ea77fea 100644 --- a/FirebaseMessaging/Sources/FIRMessaging.m +++ b/FirebaseMessaging/Sources/FIRMessaging.m @@ -1028,4 +1028,18 @@ + (NSString *)FIRMessagingSDKCurrentLocale { return [self currentLocale]; } +#pragma mark - Force Category Linking + +extern void FIRInclude_NSDictionary_FIRMessaging_Category(void); +extern void FIRInclude_NSError_FIRMessaging_Category(void); + +/// Does nothing when called, and not meant to be called. +/// +/// This method forces the linker to include categories even if +/// users do not include the '-ObjC' linker flag in their project. ++ (void)noop { + FIRInclude_NSDictionary_FIRMessaging_Category(); + FIRInclude_NSError_FIRMessaging_Category(); +} + @end diff --git a/FirebaseMessaging/Sources/NSDictionary+FIRMessaging.m b/FirebaseMessaging/Sources/NSDictionary+FIRMessaging.m index f204e86a980..d9f9450fbba 100644 --- a/FirebaseMessaging/Sources/NSDictionary+FIRMessaging.m +++ b/FirebaseMessaging/Sources/NSDictionary+FIRMessaging.m @@ -56,3 +56,7 @@ - (NSDictionary *)fcm_trimNonStringValues { } @end + +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_NSDictionary_FIRMessaging_Category(void) { +} diff --git a/FirebaseMessaging/Sources/NSError+FIRMessaging.m b/FirebaseMessaging/Sources/NSError+FIRMessaging.m index 242c527a1e0..dcd1ecfe098 100644 --- a/FirebaseMessaging/Sources/NSError+FIRMessaging.m +++ b/FirebaseMessaging/Sources/NSError+FIRMessaging.m @@ -27,3 +27,7 @@ + (NSError *)messagingErrorWithCode:(FIRMessagingErrorCode)errorCode } @end + +/// Stub used to force the linker to include the categories in this file. +void FIRInclude_NSError_FIRMessaging_Category(void) { +}