Skip to content

Commit 1742b15

Browse files
authored
fix(apple): don't include bridge code in bridgeless mode (#2775)
1 parent 6c075c0 commit 1742b15

8 files changed

Lines changed: 27 additions & 13 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/example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ PODS:
18191819
- React-utils (= 0.85.1)
18201820
- ReactNativeDependencies
18211821
- ReactNativeDependencies (0.85.1)
1822-
- ReactNativeHost (0.5.16):
1822+
- ReactNativeHost (0.5.17):
18231823
- hermes-engine
18241824
- RCTRequired
18251825
- RCTTypeSafety
@@ -2189,8 +2189,8 @@ SPEC CHECKSUMS:
21892189
ReactCodegen: 1663f3db0221878329f993847de1c422d6af5e3c
21902190
ReactCommon: 66763e5bd1b778828ff6cb82d771b7162a5215c2
21912191
ReactNativeDependencies: 8cbd0fbc0255c3949672a00a81fc8d60a29dcfd9
2192-
ReactNativeHost: 60fee0812001bb7fe6b917c3bd75744c05034950
2193-
ReactTestApp-DevSupport: 356dd447fab548be5afb29613df2a18a1dfe7ec7
2192+
ReactNativeHost: bfc03f71af9ea8533b3f77493ca49d6c40093397
2193+
ReactTestApp-DevSupport: aeb3fe7bc1b2916413ac41309a70a0df7475f8a5
21942194
ReactTestApp-Resources: 1bd9ff10e4c24f2ad87101a32023721ae923bccf
21952195
RNWWebStorage: e01ec77abc9866d80b0c1b0d57914cce11ab747b
21962196
Yoga: b1085f68c014785350a2afdc95eaef0d49f23ccb

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

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
},
8787
"dependencies": {
8888
"@isaacs/cliui": "^9.0.0",
89-
"@rnx-kit/react-native-host": "^0.5.15",
89+
"@rnx-kit/react-native-host": "^0.5.17",
9090
"@rnx-kit/tools-react-native": "^2.1.0",
9191
"ajv": "^8.0.0",
9292
"fast-xml-parser": "^5.7.0",

packages/example-macos/macos/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ PODS:
22592259
- React-perflogger (= 0.81.5)
22602260
- React-utils (= 0.81.5)
22612261
- SocketRocket
2262-
- ReactNativeHost (0.5.16):
2262+
- ReactNativeHost (0.5.17):
22632263
- boost
22642264
- DoubleConversion
22652265
- fast_float
@@ -2636,10 +2636,10 @@ SPEC CHECKSUMS:
26362636
React-timing: 6fa0e6755deb2a960c61e4589c28475e654d2c35
26372637
React-utils: 88c9727bb85bc5a1a0630370a1ff9ba0b4da21ae
26382638
ReactAppDependencyProvider: dddd83e92ff2e76331e033a983785f1f242e0485
2639-
ReactCodegen: 6ad42e680f38b7c2b12fc083db2a709e8e8c4643
2639+
ReactCodegen: b71171467ffb01846451b0fa0ac5b207741f1a96
26402640
ReactCommon: 2024e8fc1841d1e289c5bc5b26aaf0e6ced45142
2641-
ReactNativeHost: ba9bdd449af5c793d28ff2610c1bec3015d014cc
2642-
ReactTestApp-DevSupport: 356dd447fab548be5afb29613df2a18a1dfe7ec7
2641+
ReactNativeHost: 66a23d7106b451f1a1087f565a45c839abef1e73
2642+
ReactTestApp-DevSupport: 4d0b86847c5f7fffa0f09479443be7a2420d19a4
26432643
ReactTestApp-Resources: 71a3155bca10819738469de1f161410f43528209
26442644
RNWWebStorage: 8ec03f8288c1e212518f662f44ec223603bbe74c
26452645
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,12 +4496,12 @@ __metadata:
44964496
languageName: node
44974497
linkType: hard
44984498

4499-
"@rnx-kit/react-native-host@npm:^0.5.15":
4500-
version: 0.5.16
4501-
resolution: "@rnx-kit/react-native-host@npm:0.5.16"
4499+
"@rnx-kit/react-native-host@npm:^0.5.17":
4500+
version: 0.5.17
4501+
resolution: "@rnx-kit/react-native-host@npm:0.5.17"
45024502
peerDependencies:
45034503
react-native: ">=0.66"
4504-
checksum: 10c0/346aa558a9fbe1e36c544ddcd2e85b1f111dec1250700e3a2326d3c171f33fed1e7f4f7291bbc6bc0dcbb81c648261cb872ff334d7d970684ae05d92e84ba0d3
4504+
checksum: 10c0/e9ab5c489758274def1d910c1f6855aeb04b8b8c4e17d71ea195f252dc1416f7dc29e743797532f80ab65dd6f4c8c596fbccc29df820c093c658b104b8d52a1c
45054505
languageName: node
45064506
linkType: hard
45074507

@@ -12992,7 +12992,7 @@ __metadata:
1299212992
"@react-native-community/cli-types": "npm:^20.1.0"
1299312993
"@react-native-community/template": "npm:^0.85.0"
1299412994
"@rnx-kit/lint-lockfile": "npm:^0.1.0"
12995-
"@rnx-kit/react-native-host": "npm:^0.5.15"
12995+
"@rnx-kit/react-native-host": "npm:^0.5.17"
1299612996
"@rnx-kit/tools-react-native": "npm:^2.1.0"
1299712997
"@rnx-kit/tsconfig": "npm:^3.0.1"
1299812998
"@types/js-yaml": "npm:^4.0.5"

0 commit comments

Comments
 (0)