Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose React Native version as a symbol rather than macro #18136

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion React/Base/RCTPlatform.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ + (BOOL)requiresMainQueueSetup
@"systemName": [device systemName],
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
@"isTesting": @(RCTRunningInTestEnvironment()),
@"reactNativeVersion": RCT_REACT_NATIVE_VERSION,
@"reactNativeVersion": RCTGetReactNativeVersion(),
};
}

Expand Down
17 changes: 9 additions & 8 deletions React/Base/RCTVersion.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/**
* @generated by scripts/bump-oss-version.js
*
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#define RCT_REACT_NATIVE_VERSION @{ \
@"major": @(0), \
@"minor": @(0), \
@"patch": @(0), \
@"prerelease": [NSNull null], \
}

#import <Foundation/Foundation.h>

extern NSString* const RCTVersionMajor;
extern NSString* const RCTVersionMinor;
extern NSString* const RCTVersionPatch;
extern NSString* const RCTVersionPrerelease;

extern NSDictionary* RCTGetReactNativeVersion(void);
33 changes: 33 additions & 0 deletions React/Base/RCTVersion.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @generated by scripts/bump-oss-version.js
*
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "RCTVersion.h"

NSString* const RCTVersionMajor = @"major";
NSString* const RCTVersionMinor = @"minor";
NSString* const RCTVersionPatch = @"patch";
NSString* const RCTVersionPrerelease = @"prerelease";

static NSDictionary* __rnVersion;

__attribute__((constructor))
static void __makeVersion()
{
__rnVersion = @{
RCTVersionMajor: @(0),
RCTVersionMinor: @(0),
RCTVersionPatch: @(0),
RCTVersionPrerelease: [NSNull null],
};
}

NSDictionary* RCTGetReactNativeVersion(void)
{
return __rnVersion;
}
8 changes: 8 additions & 0 deletions React/React.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@
352DCFF01D19F4C20056D623 /* RCTI18nUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 352DCFEF1D19F4C20056D623 /* RCTI18nUtil.m */; };
369123E11DDC75850095B341 /* RCTJSCSamplingProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 369123E01DDC75850095B341 /* RCTJSCSamplingProfiler.m */; };
391E86A41C623EC800009732 /* RCTTouchEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 391E86A21C623EC800009732 /* RCTTouchEvent.m */; };
39C50FF92046EACF00CEE534 /* RCTVersion.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 199B8A6E1F44DB16005DEF67 /* RCTVersion.h */; };
39C50FFB2046EE3500CEE534 /* RCTVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 39C50FFA2046EE3500CEE534 /* RCTVersion.m */; };
39C50FFC2046EE3500CEE534 /* RCTVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 39C50FFA2046EE3500CEE534 /* RCTVersion.m */; };
3D05745A1DE5FFF500184BB4 /* RCTJavaScriptLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */; };
3D0B84221EC0B3F600B2BD8E /* RCTResizeMode.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3D1FA0851DE4F3A000E03CC6 /* RCTResizeMode.h */; };
3D0B84231EC0B40D00B2BD8E /* RCTImageLoader.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3D1FA0831DE4F3A000E03CC6 /* RCTImageLoader.h */; };
Expand Down Expand Up @@ -1589,6 +1592,7 @@
dstPath = include/React;
dstSubfolderSpec = 16;
files = (
39C50FF92046EACF00CEE534 /* RCTVersion.h in Copy Headers */,
591F78DE202ADB8F004A668C /* RCTLayout.h in Copy Headers */,
59EDBCBD1FDF4E43003573DE /* RCTScrollableProtocol.h in Copy Headers */,
59EDBCBE1FDF4E43003573DE /* (null) in Copy Headers */,
Expand Down Expand Up @@ -2059,6 +2063,7 @@
369123E01DDC75850095B341 /* RCTJSCSamplingProfiler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTJSCSamplingProfiler.m; sourceTree = "<group>"; };
391E86A21C623EC800009732 /* RCTTouchEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTouchEvent.m; sourceTree = "<group>"; };
391E86A31C623EC800009732 /* RCTTouchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTouchEvent.h; sourceTree = "<group>"; };
39C50FFA2046EE3500CEE534 /* RCTVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVersion.m; sourceTree = "<group>"; };
3D0B84281EC0B49400B2BD8E /* RCTTVRemoteHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTVRemoteHandler.h; sourceTree = "<group>"; };
3D0B84291EC0B49400B2BD8E /* RCTTVRemoteHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTVRemoteHandler.m; sourceTree = "<group>"; };
3D0B842D1EC0B51200B2BD8E /* RCTTVNavigationEventEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTVNavigationEventEmitter.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2997,6 +3002,7 @@
83CBBA4F1A601E3B00E9B192 /* RCTUtils.h */,
83CBBA501A601E3B00E9B192 /* RCTUtils.m */,
199B8A6E1F44DB16005DEF67 /* RCTVersion.h */,
39C50FFA2046EE3500CEE534 /* RCTVersion.m */,
599FAA291FB274970058CCF6 /* Surface */,
);
path = Base;
Expand Down Expand Up @@ -4153,6 +4159,7 @@
5960C1BC1F0804A00066FD5B /* RCTLayoutAnimationGroup.m in Sources */,
2D3B5ECF1D9B096F00451313 /* RCTFont.mm in Sources */,
2D3B5ED51D9B098000451313 /* RCTModalHostViewController.m in Sources */,
39C50FFC2046EE3500CEE534 /* RCTVersion.m in Sources */,
2D3B5EBC1D9B092600451313 /* RCTKeyboardObserver.m in Sources */,
657734931EE8356100A0E9EA /* RCTInspector.mm in Sources */,
59EB6DBE1EBD6FC90072A5E7 /* RCTUIManagerObserverCoordinator.mm in Sources */,
Expand Down Expand Up @@ -4467,6 +4474,7 @@
13D9FEEB1CDCCECF00158BD7 /* RCTEventEmitter.m in Sources */,
599FAA3E1FB274980058CCF6 /* RCTSurfaceRootShadowView.m in Sources */,
AC70D2E91DE489E4002E6351 /* RCTJavaScriptLoader.mm in Sources */,
39C50FFB2046EE3500CEE534 /* RCTVersion.m in Sources */,
14F7A0EC1BDA3B3C003C6C10 /* RCTPerfMonitor.m in Sources */,
5960C1B71F0804A00066FD5B /* RCTLayoutAnimation.m in Sources */,
13134C9E1E296B2A00B9F3CB /* RCTCxxModule.mm in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions scripts/bump-oss-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ fs.writeFileSync(
);

fs.writeFileSync(
'React/Base/RCTVersion.h',
cat('scripts/versiontemplates/RCTVersion.h.template')
'React/Base/RCTVersion.m',
cat('scripts/versiontemplates/RCTVersion.m.template')
.replace('${major}', `@(${major})`)
.replace('${minor}', `@(${minor})`)
.replace('${patch}', `@(${patch})`)
Expand Down
15 changes: 0 additions & 15 deletions scripts/versiontemplates/RCTVersion.h.template

This file was deleted.

33 changes: 33 additions & 0 deletions scripts/versiontemplates/RCTVersion.m.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @generated by scripts/bump-oss-version.js
*
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "RCTVersion.h"

NSString* const RCTVersionMajor = @"major";
NSString* const RCTVersionMinor = @"minor";
NSString* const RCTVersionPatch = @"patch";
NSString* const RCTVersionPrerelease = @"prerelease";

static NSDictionary* __rnVersion;

__attribute__((constructor))
static void __makeVersion()
{
__rnVersion = @{
RCTVersionMajor: ${major},
RCTVersionMinor: ${minor},
RCTVersionPatch: ${patch},
RCTVersionPrerelease: ${prerelease},
};
}

NSDictionary* RCTGetReactNativeVersion(void)
{
return __rnVersion;
}