Skip to content

Commit e2848ce

Browse files
committed
fix(apple): don't compile bridge code in bridgeless mode
1 parent 2cbd82e commit e2848ce

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/app/ReactTestApp-DevSupport.podspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ end
1717

1818
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
1919
version = package['version']
20+
preprocessor_definitions = ENV['USE_BRIDGELESS'] == '1' ? ['USE_BRIDGELESS=1'] : []
2021

2122
Pod::Spec.new do |s|
2223
s.name = File.basename(__FILE__, '.podspec')
@@ -37,6 +38,8 @@ Pod::Spec.new do |s|
3738
s.pod_target_xcconfig = {
3839
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
3940
'DEFINES_MODULE' => 'YES',
41+
'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
42+
'CPP_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
4043
'SWIFT_OBJC_BRIDGING_HEADER' =>
4144
'ios/ReactTestApp/Public/ReactTestApp-DevSupport-Bridging-Header.h',
4245
}

packages/app/ios/ReactTestApp/AppRegistryModule.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
#import <jsi/jsi.h>
44

5+
#if !USE_BRIDGELESS
56
#import <React/RCTBridge.h>
7+
#endif // !USE_BRIDGELESS
68

79
#import "AppRegistry.h"
810
#import "ReactTestApp-DevSupport.h"
911

1012
using facebook::jsi::Runtime;
1113

14+
#if !USE_BRIDGELESS
1215
@interface RCTCxxBridge : RCTBridge
1316
@property (nonatomic, readonly) void *runtime;
1417
- (void)invokeAsync:(std::function<void()> &&)func;
1518
@end
19+
#endif // !USE_BRIDGELESS
1620

1721
void RTAPostDidRegisterAppsNotification(NSValue *value)
1822
{
@@ -32,6 +36,7 @@ void RTAPostDidRegisterAppsNotification(NSValue *value)
3236
userInfo:@{@"appKeys": [array copy]}];
3337
}
3438

39+
#if !USE_BRIDGELESS
3540
void RTAPostDidRegisterAppsNotificationWithBridge(id bridge)
3641
{
3742
if (![bridge isKindOfClass:[RCTCxxBridge class]] ||
@@ -50,3 +55,4 @@ void RTAPostDidRegisterAppsNotificationWithBridge(id bridge)
5055
RTAPostDidRegisterAppsNotification([NSValue valueWithPointer:runtime]);
5156
}];
5257
}
58+
#endif // !USE_BRIDGELESS

packages/app/ios/ReactTestApp/Public/ReactTestApp-DevSupport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ OBJC_EXTERN NSNotificationName const ReactTestAppSceneDidOpenURLNotification
2626
OBJC_EXTERN NSNotificationName const ReactInstanceDidLoadBundle;
2727

2828
OBJC_EXTERN void RTAPostDidRegisterAppsNotification(NSValue *runtime);
29+
30+
#if !USE_BRIDGELESS
2931
OBJC_EXTERN void RTAPostDidRegisterAppsNotificationWithBridge(id bridge);
32+
#endif // !USE_BRIDGELESS
3033

3134
NS_ASSUME_NONNULL_END

packages/app/ios/ReactTestApp/ReactInstance.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ final class ReactInstance: NSObject, RNXHostConfig {
219219
#endif
220220
}
221221

222+
#if !USE_BRIDGELESS
222223
if let bridge = notification.userInfo?["bridge"] {
223224
RTAPostDidRegisterAppsNotificationWithBridge(bridge)
224225
}
226+
#endif // !USE_BRIDGELESS
225227
}
226228

227229
@objc

0 commit comments

Comments
 (0)