Skip to content

Commit e612b9b

Browse files
fkgozalifacebook-github-bot
authored andcommitted
TM iOS: Install TurboModule system in RNTester (pod) by default
Summary: For CocoaPods variant only: install TurboModule binding so that sample modules can start using it. This commit only installs `global.__turboModuleProxy` - no sample module is provided. Note: RNTester.xcodeproj will NOT have TurboModule enabled, due to complication in the .xcodeproj setup (doable, but maybe for some other time...) To test: ``` console.error(global.__turboModuleProxy == null ? 'BOO' : 'YAY!'); ``` Saw `YAY!` in RNTester pod version. Reviewed By: cpojer Differential Revision: D14932536 fbshipit-source-id: 3dc083da9154ec320ce6789ec7f2cef5a08fd6a7
1 parent 642faff commit e612b9b

4 files changed

Lines changed: 68 additions & 8 deletions

File tree

RNTester/Podfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ target 'RNTester' do
3737
pod 'React-jsinspector', :path => '../ReactCommon/jsinspector'
3838
pod 'yoga', :path => '../ReactCommon/yoga'
3939

40-
# Uncomment to enable TurboModule
41-
# pod 'React-turbomodule-core', :path => '../ReactCommon/turbomodule/core'
40+
pod 'React-turbomodule-core', :path => '../ReactCommon/turbomodule/core'
4241

4342
# Third party deps podspec link
4443
pod 'DoubleConversion', :podspec => '../third-party-podspecs/DoubleConversion.podspec'

RNTester/Podfile.lock

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ PODS:
8888
- React-RCTWebSocket (1000.0.0):
8989
- React-Core (= 1000.0.0)
9090
- React-fishhook (= 1000.0.0)
91+
- React-turbomodule-core (1000.0.0):
92+
- Folly (= 2018.10.22.00)
93+
- React-Core (= 1000.0.0)
94+
- React-cxxreact (= 1000.0.0)
95+
- React-jsi (= 1000.0.0)
96+
- React-turbomodule-core/core-ios (= 1000.0.0)
97+
- React-turbomodule-core/core-ios (1000.0.0):
98+
- Folly (= 2018.10.22.00)
99+
- React-Core (= 1000.0.0)
100+
- React-cxxreact (= 1000.0.0)
101+
- React-jsi (= 1000.0.0)
91102
- yoga (1000.0.0.React)
92103

93104
DEPENDENCIES:
@@ -115,6 +126,7 @@ DEPENDENCIES:
115126
- React-RCTText (from `../Libraries/Text`)
116127
- React-RCTVibration (from `../Libraries/Vibration`)
117128
- React-RCTWebSocket (from `../Libraries/WebSocket`)
129+
- React-turbomodule-core (from `../ReactCommon/turbomodule/core`)
118130
- yoga (from `../ReactCommon/yoga`)
119131

120132
SPEC REPOS:
@@ -170,6 +182,8 @@ EXTERNAL SOURCES:
170182
:path: "../Libraries/Vibration"
171183
React-RCTWebSocket:
172184
:path: "../Libraries/WebSocket"
185+
React-turbomodule-core:
186+
:path: "../ReactCommon/turbomodule/core"
173187
yoga:
174188
:path: "../ReactCommon/yoga"
175189

@@ -199,8 +213,9 @@ SPEC CHECKSUMS:
199213
React-RCTText: 469ec754592c92fc639825e558908c2f0e783e2c
200214
React-RCTVibration: ade3c169b54f3bc16c9a9918e17e48ef66aee6ba
201215
React-RCTWebSocket: 90b78ed51d53d17db417d3956decba3f7ace58e4
216+
React-turbomodule-core: d4c0c7d6a7d97e25ac6d0316c2a7950d199b398e
202217
yoga: 542cb34fe3bca476487e08eb516dd640ea996a65
203218

204-
PODFILE CHECKSUM: ab35b96fa954669fff47b015261668e4be104900
219+
PODFILE CHECKSUM: e587e581dcf974f8a9b7b1ff624f5114082b8045
205220

206221
COCOAPODS: 1.6.1

RNTester/RNTester/AppDelegate.mm

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,44 @@
2525
#ifdef RN_FABRIC_ENABLED
2626
#import <React/RCTSurfacePresenter.h>
2727
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
28+
#endif
29+
30+
#ifdef RN_TURBO_MODULE_ENABLED
31+
#import <React/RCTTurboModuleManager.h>
32+
#endif
2833

34+
#ifdef RN_TURBO_MODULE_ENABLED
35+
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{
36+
#else
2937
@interface AppDelegate() <RCTCxxBridgeDelegate>{
38+
#endif
39+
40+
#ifdef RN_FABRIC_ENABLED
3041
RCTSurfacePresenter *_surfacePresenter;
42+
#endif
43+
44+
#ifdef RN_TURBO_MODULE_ENABLED
45+
RCTTurboModuleManager *_turboModuleManager;
46+
#endif
47+
3148
}
3249
@end
3350

51+
#ifdef RN_FABRIC_ENABLED
3452
// FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910
3553
@interface RCTSurfacePresenter ()
3654
-(void)_startAllSurfaces;
3755
@end
38-
39-
#else
40-
@interface AppDelegate() <RCTCxxBridgeDelegate>
41-
@end
4256
#endif
4357

4458
@implementation AppDelegate
4559

4660
- (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
4761
{
62+
#ifdef RN_TURBO_MODULE_ENABLED
63+
RCTEnableTurboModule(YES);
64+
#endif
65+
4866
_bridge = [[RCTBridge alloc] initWithDelegate:self
4967
launchOptions:launchOptions];
5068

@@ -120,11 +138,38 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge
120138
}
121139
__typeof(self) strongSelf = weakSelf;
122140
if (strongSelf) {
123-
// TODO: Install bindings to the JS runtime.
141+
#ifdef RN_TURBO_MODULE_ENABLED
142+
strongSelf->_turboModuleManager = [[RCTTurboModuleManager alloc] initWithRuntime:&runtime bridge:bridge delegate:strongSelf];
143+
[strongSelf->_turboModuleManager installJSBinding];
144+
#endif
124145
}
125146
});
126147
}
127148

149+
#pragma mark RCTTurboModuleManagerDelegate
150+
151+
#ifdef RN_TURBO_MODULE_ENABLED
152+
153+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
154+
jsInvoker:(std::shared_ptr<facebook::react::JSCallInvoker>)jsInvoker
155+
{
156+
return nullptr;
157+
}
158+
159+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
160+
instance:(id<RCTTurboModule>)instance
161+
jsInvoker:(std::shared_ptr<facebook::react::JSCallInvoker>)jsInvoker
162+
{
163+
return nullptr;
164+
}
165+
166+
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
167+
{
168+
return nil;
169+
}
170+
171+
#endif
172+
128173
# pragma mark - Push Notifications
129174

130175
#if !TARGET_OS_TV

ReactCommon/turbomodule/core/React-turbomodule-core.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Pod::Spec.new do |s|
3434
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
3535
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/Folly\"" }
3636
s.header_dir = "jsireact"
37+
s.xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_TURBO_MODULE_ENABLED" }
3738

3839
s.dependency "React-Core", version
3940
s.dependency "React-cxxreact", version

0 commit comments

Comments
 (0)