Skip to content

Commit b3e0ea9

Browse files
authored
initial commit (#8209)
* initial commit * version detection logic updated
1 parent bed7214 commit b3e0ea9

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,3 @@ Gemfile.lock
254254
!.yarn/sdks
255255
!.yarn/versions
256256

257-
/ios/ReactNativeVersionExtracted.h

ReactNativeNavigation.podspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use_hermes_flag = use_hermes ? "-DUSE_HERMES=1" : ""
88

99
Pod::Spec.new do |s|
1010
s.name = "ReactNativeNavigation"
11-
s.prepare_command = 'node autolink/postlink/__helpers__/generate_version_header.js'
1211
s.version = package['version']
1312
s.summary = package['description']
1413

@@ -24,8 +23,7 @@ Pod::Spec.new do |s|
2423
s.exclude_files = "ios/ReactNativeNavigationTests/**/*.*", "ios/OCMock/**/*.*"
2524

2625
s.public_header_files = [
27-
'ios/RNNAppDelegate.h',
28-
'ios/ReactNativeVersionExtracted.h'
26+
'ios/RNNAppDelegate.h'
2927
]
3028

3129
# Add Folly compiler flags to prevent coroutines header issues

ios/RNNAppDelegate.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
#import <Foundation/Foundation.h>
22
#import <React/CoreModulesPlugins.h>
3-
#import <ReactNativeNavigation/ReactNativeVersionExtracted.h>
43

5-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
4+
// Detect RN 0.79+ by checking for RCTJSRuntimeConfiguratorProtocol.h (added in 0.79)
5+
#if __has_include(<React-RCTAppDelegate/RCTJSRuntimeConfiguratorProtocol.h>) || \
6+
__has_include(<React_RCTAppDelegate/RCTJSRuntimeConfiguratorProtocol.h>)
7+
#define RNN_RN_VERSION_79_OR_NEWER 1
8+
#else
9+
#define RNN_RN_VERSION_79_OR_NEWER 0
10+
// Detect RN 0.78 by checking for RCTReactNativeFactory.h (added in 0.78, doesn't exist in 0.77)
11+
#if __has_include(<React-RCTAppDelegate/RCTReactNativeFactory.h>) || \
12+
__has_include(<React_RCTAppDelegate/RCTReactNativeFactory.h>)
13+
#define RNN_RN_VERSION_78 1
14+
#else
15+
#define RNN_RN_VERSION_78 0
16+
#endif
17+
#endif
18+
19+
#if !RNN_RN_VERSION_79_OR_NEWER
620
#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
721
#import <React-RCTAppDelegate/RCTAppDelegate.h>
822
#elif __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
@@ -30,7 +44,7 @@
3044

3145
#import <React/RCTBundleURLProvider.h>
3246

33-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
47+
#if !RNN_RN_VERSION_79_OR_NEWER
3448
@interface RNNAppDelegate : RCTAppDelegate
3549
#else
3650
@interface RNNAppDelegate : UIResponder <UIApplicationDelegate>

ios/RNNAppDelegate.mm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@
3030

3131
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
3232

33-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
34-
@interface RNNAppDelegate () <RCTTurboModuleManagerDelegate,
35-
RCTComponentViewFactoryComponentProvider> {
36-
}
37-
@end
33+
#if !RNN_RN_VERSION_79_OR_NEWER
34+
@interface RNNAppDelegate () <RCTTurboModuleManagerDelegate,
35+
RCTComponentViewFactoryComponentProvider> {
36+
}
37+
@end
3838
#else
39-
@interface RNNAppDelegate () {
40-
}
41-
@end
39+
@interface RNNAppDelegate () {
40+
}
41+
@end
4242
#endif
4343

4444
@implementation RNNAppDelegate
4545

4646
- (BOOL)application:(UIApplication *)application
4747
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
4848

49-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
49+
#if !RNN_RN_VERSION_79_OR_NEWER
5050
[self _setUpFeatureFlags];
51-
#if RN_VERSION_MINOR == 77
51+
#if !RNN_RN_VERSION_78
5252
self.rootViewFactory = [self createRCTRootViewFactory];
5353
#else
5454
self.reactNativeFactory = [[RCTReactNativeFactory alloc] init];
@@ -82,7 +82,7 @@ - (BOOL)application:(UIApplication *)application
8282
}
8383

8484

85-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
85+
#if !RNN_RN_VERSION_79_OR_NEWER
8686
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
8787
[NSException raise:@"RCTBridgeDelegate::sourceURLForBridge not implemented"
8888
format:@"Subclasses must implement a valid sourceURLForBridge method"];

playground/ios/playground/AppDelegate.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#import "RNNCustomViewController.h"
33
#import <ReactNativeNavigation/ReactNativeNavigation.h>
44

5-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
5+
#if !RNN_RN_VERSION_79_OR_NEWER
66
@interface AppDelegate () <RCTBridgeDelegate>
77
@end
88
#else
@@ -35,14 +35,14 @@ @implementation AppDelegate
3535

3636
- (BOOL)application:(UIApplication *)application
3737
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
38-
#if (RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR >= 79) || RN_VERSION_MAJOR > 0
38+
#if RNN_RN_VERSION_79_OR_NEWER
3939
self.reactNativeDelegate = [ReactNativeDelegate new];
4040
#endif
4141

4242
[super application:application didFinishLaunchingWithOptions:launchOptions];
4343

4444

45-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
45+
#if !RNN_RN_VERSION_79_OR_NEWER
4646
self.dependencyProvider = [RCTAppDependencyProvider new];
4747
#endif
4848

@@ -55,7 +55,7 @@ - (BOOL)application:(UIApplication *)application
5555
return YES;
5656
}
5757

58-
#if RN_VERSION_MAJOR == 0 && RN_VERSION_MINOR < 79
58+
#if !RNN_RN_VERSION_79_OR_NEWER
5959
#pragma mark - RCTBridgeDelegate
6060
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
6161
{

0 commit comments

Comments
 (0)