Skip to content

Commit

Permalink
Workaround for bridge.isInspectable
Browse files Browse the repository at this point in the history
Summary:
`RCTDevSettings` uses the API `bridge.isInspectable` to understand if the runtime can be debugged. In bridgeless mode, let's use `RuntimeExecutor` to check the same property.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D27095935

fbshipit-source-id: 93785774b175bd7da17269e1590b5d92eba2b0cf
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Mar 18, 2021
1 parent 4079c04 commit dbf5fa2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions React/CoreModules/RCTDevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@

@end

@protocol RCTDevSettingsInspectable <NSObject>

/**
* Whether current jsi::Runtime is inspectable.
* Only set when using as a bridgeless turbo module.
*/
@property (nonatomic, assign, readwrite) BOOL isInspectable;

@end

@interface RCTDevSettings : RCTEventEmitter

- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource;
Expand Down
14 changes: 12 additions & 2 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ - (void)_reloadWithDefaults:(NSDictionary *)defaultValues

@end

@interface RCTDevSettings () <RCTBridgeModule, RCTInvalidating, NativeDevSettingsSpec, RCTBundleHolderModule> {
@interface RCTDevSettings () <
RCTBridgeModule,
RCTInvalidating,
NativeDevSettingsSpec,
RCTBundleHolderModule,
RCTDevSettingsInspectable> {
BOOL _isJSLoaded;
#if ENABLE_PACKAGER_CONNECTION
RCTHandlerToken _reloadToken;
Expand All @@ -129,6 +134,7 @@ @interface RCTDevSettings () <RCTBridgeModule, RCTInvalidating, NativeDevSetting
@implementation RCTDevSettings

@synthesize bundleURL = _bundleURL;
@synthesize isInspectable = _isInspectable;

RCT_EXPORT_MODULE()

Expand Down Expand Up @@ -242,7 +248,11 @@ - (id)settingForKey:(NSString *)key
- (BOOL)isDeviceDebuggingAvailable
{
#if RCT_ENABLE_INSPECTOR
return self.bridge.isInspectable;
if (self.bridge) {
return self.bridge.isInspectable;
} else {
return self.isInspectable;
}
#else
return false;
#endif // RCT_ENABLE_INSPECTOR
Expand Down

0 comments on commit dbf5fa2

Please sign in to comment.