[ObjC] Improve handing of the WKT ObjC Category additions.
Include a comment in the generated header about there being helpers
in GPBWellKnowTypes.h
Generate some extra code for the WKTs that have categories to help
ensure the categories get linked so developers don't have to use
-ObjC in some cases.
PiperOrigin-RevId: 589179237
diff --git a/objectivec/GPBAny.pbobjc.h b/objectivec/GPBAny.pbobjc.h
index c0d389f..a9ae0c5 100644
--- a/objectivec/GPBAny.pbobjc.h
+++ b/objectivec/GPBAny.pbobjc.h
@@ -168,6 +168,9 @@
/** Must be a valid serialized protocol buffer of the above specified type. */
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
+// NOTE: There are some Objective-C specific methods/properties in
+// GPBWellKnownTypes.h that will likey be useful.
+
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBAny.pbobjc.m b/objectivec/GPBAny.pbobjc.m
index be6ce4e..65207e8 100644
--- a/objectivec/GPBAny.pbobjc.m
+++ b/objectivec/GPBAny.pbobjc.m
@@ -3,6 +3,7 @@
// source: google/protobuf/any.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
+#import "GPBWellKnownTypes.h"
#import "GPBAny.pbobjc.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
@@ -39,6 +40,13 @@
.syntax = GPBFileSyntaxProto3
};
+// This is to help make sure that the GPBWellKnownTypes.* categories get linked and
+// developers do not have to use the `-ObjC` linker flag. More information
+// here: https://medium.com/ios-os-x-development/categories-in-static-libraries-78e41f8ddb96
+__attribute__((used)) static NSString* any_importCategories () {
+ return GPBWellKnownTypesErrorDomain;
+}
+
#pragma mark - GPBAny
@implementation GPBAny
diff --git a/objectivec/GPBDuration.pbobjc.h b/objectivec/GPBDuration.pbobjc.h
index 9e67afc..c5e27e4 100644
--- a/objectivec/GPBDuration.pbobjc.h
+++ b/objectivec/GPBDuration.pbobjc.h
@@ -123,6 +123,9 @@
**/
@property(nonatomic, readwrite) int32_t nanos;
+// NOTE: There are some Objective-C specific methods/properties in
+// GPBWellKnownTypes.h that will likey be useful.
+
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBDuration.pbobjc.m b/objectivec/GPBDuration.pbobjc.m
index f53c022..124342f 100644
--- a/objectivec/GPBDuration.pbobjc.m
+++ b/objectivec/GPBDuration.pbobjc.m
@@ -3,6 +3,7 @@
// source: google/protobuf/duration.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
+#import "GPBWellKnownTypes.h"
#import "GPBDuration.pbobjc.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
@@ -39,6 +40,13 @@
.syntax = GPBFileSyntaxProto3
};
+// This is to help make sure that the GPBWellKnownTypes.* categories get linked and
+// developers do not have to use the `-ObjC` linker flag. More information
+// here: https://medium.com/ios-os-x-development/categories-in-static-libraries-78e41f8ddb96
+__attribute__((used)) static NSString* duration_importCategories () {
+ return GPBWellKnownTypesErrorDomain;
+}
+
#pragma mark - GPBDuration
@implementation GPBDuration
diff --git a/objectivec/GPBTimestamp.pbobjc.h b/objectivec/GPBTimestamp.pbobjc.h
index 510ecc0..bdf8ee4 100644
--- a/objectivec/GPBTimestamp.pbobjc.h
+++ b/objectivec/GPBTimestamp.pbobjc.h
@@ -152,6 +152,9 @@
**/
@property(nonatomic, readwrite) int32_t nanos;
+// NOTE: There are some Objective-C specific methods/properties in
+// GPBWellKnownTypes.h that will likey be useful.
+
@end
NS_ASSUME_NONNULL_END
diff --git a/objectivec/GPBTimestamp.pbobjc.m b/objectivec/GPBTimestamp.pbobjc.m
index f2b44fd..faf2015 100644
--- a/objectivec/GPBTimestamp.pbobjc.m
+++ b/objectivec/GPBTimestamp.pbobjc.m
@@ -3,6 +3,7 @@
// source: google/protobuf/timestamp.proto
#import "GPBProtocolBuffers_RuntimeSupport.h"
+#import "GPBWellKnownTypes.h"
#import "GPBTimestamp.pbobjc.h"
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30007
@@ -39,6 +40,13 @@
.syntax = GPBFileSyntaxProto3
};
+// This is to help make sure that the GPBWellKnownTypes.* categories get linked and
+// developers do not have to use the `-ObjC` linker flag. More information
+// here: https://medium.com/ios-os-x-development/categories-in-static-libraries-78e41f8ddb96
+__attribute__((used)) static NSString* timestamp_importCategories () {
+ return GPBWellKnownTypesErrorDomain;
+}
+
#pragma mark - GPBTimestamp
@implementation GPBTimestamp