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:
Pull Request resolved: facebook#39582

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

fbshipit-source-id: b926bec49e2c67d2bc6662d32178cbb5baed2121
  • Loading branch information
huntie authored and facebook-github-bot committed Sep 21, 2023
1 parent c53dd6c commit 7f73b85
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 7f73b85

Please sign in to comment.