Skip to content

Commit

Permalink
Improve remote debugging LogBox message, cleanup unused openURL method (
Browse files Browse the repository at this point in the history
facebook#39582)

Summary:

Some tidying up around remote JS debugging while testing. See also react-native-community/cli#2083.

## Changelog:
[iOS][Breaking] - Remove `openURL` method from `RCTInspectorDevServerHelper`

Reviewed By: cipolleschi

Differential Revision: D49499068
  • Loading branch information
huntie authored and facebook-github-bot committed Sep 22, 2023
1 parent 8c5340f commit cb66d2a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ - (void)sendMessage:(NSDictionary<NSString *, id> *)message onReply:(RCTWSMessag

dispatch_async(_jsQueue, ^{
if (!self.valid) {
callback(RCTErrorWithMessage(@"Runtime is not ready for debugging. Make sure Metro is running."), nil);
callback(
RCTErrorWithMessage(
@"Runtime is not ready for debugging. Make sure Metro is running and the Remote Debugging browser window is open."),
nil);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

+ (RCTInspectorPackagerConnection *)connectWithBundleURL:(NSURL *)bundleURL;
+ (void)disableDebugger;
+ (void)openURL:(NSString *)url withBundleURL:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage;
+ (void)openDebugger:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage;
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
escapedDeviceName,
escapedAppName]];
}
static NSURL *getOpenUrlEndpoint(NSURL *bundleURL)
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/open-url", getServerHost(bundleURL)]];
}

@implementation RCTInspectorDevServerHelper

RCT_NOT_IMPLEMENTED(-(instancetype)init)
Expand All @@ -68,27 +65,6 @@ static void sendEventToAllConnections(NSString *event)
}
}

+ (void)openURL:(NSString *)url withBundleURL:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage
{
NSURL *endpoint = getOpenUrlEndpoint(bundleURL);

NSDictionary *jsonBodyDict = @{@"url" : url};
NSData *jsonBodyData = [NSJSONSerialization dataWithJSONObject:jsonBodyDict options:kNilOptions error:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:endpoint];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsonBodyData];

[[[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(
__unused NSData *_Nullable data, __unused NSURLResponse *_Nullable response, NSError *_Nullable error) {
if (error != nullptr) {
RCTLogWarn(@"%@", errorMessage);
}
}] resume];
}

+ (void)openDebugger:(NSURL *)bundleURL withErrorMessage:(NSString *)errorMessage
{
NSString *appId = [[[NSBundle mainBundle] bundleIdentifier]
Expand Down

0 comments on commit cb66d2a

Please sign in to comment.