diff --git a/React/CoreModules/RCTPlatform.mm b/React/CoreModules/RCTPlatform.mm index 69cae85879d52b..675e9a4aa80f71 100644 --- a/React/CoreModules/RCTPlatform.mm +++ b/React/CoreModules/RCTPlatform.mm @@ -50,23 +50,28 @@ - (dispatch_queue_t)methodQueue } // TODO: Use the generated struct return type. -- (NSDictionary *)constantsToExport +- (ModuleConstants)constantsToExport { - return [self getConstants]; + return (ModuleConstants)[self getConstants]; } -// TODO: Use the generated struct return type. -- (NSDictionary *)getConstants +- (ModuleConstants)getConstants { UIDevice *device = [UIDevice currentDevice]; - return @{ - @"forceTouchAvailable": @(RCTForceTouchAvailable()), - @"osVersion": [device systemVersion], - @"systemName": [device systemName], - @"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]), - @"isTesting": @(RCTRunningInTestEnvironment()), - @"reactNativeVersion": RCTGetReactNativeVersion(), - }; + auto versions = RCTGetReactNativeVersion(); + return typedConstants({ + .forceTouchAvailable = @(RCTForceTouchAvailable()), + .osVersion = [device systemVersion], + .systemName = [device systemName], + .interfaceIdiom = interfaceIdiom([device userInterfaceIdiom]), + .isTesting = @(RCTRunningInTestEnvironment()), + .reactNativeVersion = JS::NativePlatformConstantsIOS::ConstantsReactNativeVersion::Builder({ + .minor = [versions[@"minor"] doubleValue], + .major = [versions[@"major"] doubleValue], + .patch = [versions[@"patch"] doubleValue], + .prerelease = [versions[@"prerelease"] isKindOfClass: [NSNull class]] ? folly::Optional{} : [versions[@"prerelease"] doubleValue] + }), + }); } - (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker