[ObjC] Make debug runtime tell developers to update their generated code.

Migrate some internals of the library off the older apis.

Also mark some of the old apis as deprecated, but the old generated code
suppressed warnings broadly to support protobuf deprecations.

PiperOrigin-RevId: 668003974
diff --git a/objectivec/GPBDescriptor_PackagePrivate.h b/objectivec/GPBDescriptor_PackagePrivate.h
index 07c83dc..3c431db 100644
--- a/objectivec/GPBDescriptor_PackagePrivate.h
+++ b/objectivec/GPBDescriptor_PackagePrivate.h
@@ -215,14 +215,18 @@
                                  fields:(void *)fieldDescriptions
                              fieldCount:(uint32_t)fieldCount
                             storageSize:(uint32_t)storageSize
-                                  flags:(GPBDescriptorInitializationFlags)flags;
+                                  flags:(GPBDescriptorInitializationFlags)flags
+    __attribute__((deprecated("Please use a newer version of protoc to regenerate your sources. "
+                              "Support for this version will go away in the future.")));
 + (instancetype)allocDescriptorForClass:(Class)messageClass
                               rootClass:(Class)rootClass
                                    file:(GPBFileDescriptor *)file
                                  fields:(void *)fieldDescriptions
                              fieldCount:(uint32_t)fieldCount
                             storageSize:(uint32_t)storageSize
-                                  flags:(GPBDescriptorInitializationFlags)flags;
+                                  flags:(GPBDescriptorInitializationFlags)flags
+    __attribute__((deprecated("Please use a newer version of protoc to regenerate your sources. "
+                              "Support for this version will go away in the future.")));
 - (void)setupContainingMessageClassName:(const char *)msgClassName;
 - (void)setupMessageClassNameSuffix:(NSString *)suffix;
 
@@ -282,13 +286,17 @@
                             valueNames:(const char *)valueNames
                                 values:(const int32_t *)values
                                  count:(uint32_t)valueCount
-                          enumVerifier:(GPBEnumValidationFunc)enumVerifier;
+                          enumVerifier:(GPBEnumValidationFunc)enumVerifier
+    __attribute__((deprecated("Please use a newer version of protoc to regenerate your sources. "
+                              "Support for this version will go away in the future.")));
 + (instancetype)allocDescriptorForName:(NSString *)name
                             valueNames:(const char *)valueNames
                                 values:(const int32_t *)values
                                  count:(uint32_t)valueCount
                           enumVerifier:(GPBEnumValidationFunc)enumVerifier
-                   extraTextFormatInfo:(const char *)extraTextFormatInfo;
+                   extraTextFormatInfo:(const char *)extraTextFormatInfo
+    __attribute__((deprecated("Please use a newer version of protoc to regenerate your sources. "
+                              "Support for this version will go away in the future.")));
 @end
 
 @interface GPBExtensionDescriptor () {
@@ -307,7 +315,9 @@
 - (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc
                                usesClassRefs:(BOOL)usesClassRefs;
 // Deprecated. Calls above with `usesClassRefs = NO`
-- (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc;
+- (instancetype)initWithExtensionDescription:(GPBExtensionDescription *)desc
+    __attribute__((deprecated("Please use a newer version of protoc to regenerate your sources. "
+                              "Support for this version will go away in the future.")));
 
 - (NSComparisonResult)compareByFieldNumber:(GPBExtensionDescriptor *)other;
 @end
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 591ac47..4b2998f 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -1196,18 +1196,19 @@
 + (GPBDescriptor *)descriptor {
   // This is thread safe because it is called from +initialize.
   static GPBDescriptor *descriptor = NULL;
-  static GPBFileDescriptor *fileDescriptor = NULL;
+  static GPBFileDescription fileDescription = {
+      .package = "internal", .prefix = "", .syntax = GPBFileSyntaxProto2};
   if (!descriptor) {
-    fileDescriptor = [[GPBFileDescriptor alloc] initWithPackage:@"internal"
-                                                         syntax:GPBFileSyntaxProto2];
-
-    descriptor = [GPBDescriptor allocDescriptorForClass:[GPBMessage class]
-                                              rootClass:Nil
-                                                   file:fileDescriptor
-                                                 fields:NULL
-                                             fieldCount:0
-                                            storageSize:0
-                                                  flags:0];
+    descriptor = [GPBDescriptor
+        allocDescriptorForClass:[GPBMessage class]
+                    messageName:@"GPBMessage"
+                fileDescription:&fileDescription
+                         fields:NULL
+                     fieldCount:0
+                    storageSize:0
+                          flags:(GPBDescriptorInitializationFlag_UsesClassRefs |
+                                 GPBDescriptorInitializationFlag_Proto3OptionalKnown |
+                                 GPBDescriptorInitializationFlag_ClosedEnumSupportKnown)];
   }
   return descriptor;
 }
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m
index 0764c96..dc6e871 100644
--- a/objectivec/GPBUtilities.m
+++ b/objectivec/GPBUtilities.m
@@ -206,6 +206,14 @@
                        @" supports back to %d!",
                        objcRuntimeVersion, GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION];
   }
+#if defined(DEBUG) && DEBUG
+  if (objcRuntimeVersion < GOOGLE_PROTOBUF_OBJC_VERSION) {
+    // This is a version we haven't generated for yet.
+    NSLog(@"WARNING: Code from generated Objective-C proto from an older version of the library is "
+          @"being used. Please regenerate with the current version as the code will stop working "
+          @"in a future release.");
+  }
+#endif
 }
 
 void GPBRuntimeMatchFailure(void) {
diff --git a/objectivec/Tests/GPBMessageTests+ClassNames.m b/objectivec/Tests/GPBMessageTests+ClassNames.m
index 3ad5e71..010fd41 100644
--- a/objectivec/Tests/GPBMessageTests+ClassNames.m
+++ b/objectivec/Tests/GPBMessageTests+ClassNames.m
@@ -14,6 +14,9 @@
 #import "GPBMessage.h"
 #import "GPBRootObject_PackagePrivate.h"
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
 // Support classes for tests using old class name (vs classrefs) interfaces.
 GPB_FINAL @interface MessageLackingClazzRoot : GPBRootObject
 @end
@@ -107,6 +110,8 @@
 }
 @end
 
+#pragma clang diagnostic pop
+
 @interface MessageClassNameTests : GPBTestCase
 @end