Improve remote debugging LogBox message, cleanup unused openURL method (#39582)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39582

Some tidying up around remote JS debugging while testing. See also https://github.com/react-native-community/cli/pull/2083.

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

Reviewed By: cipolleschi

Differential Revision: D49499068

fbshipit-source-id: 843ef6cf1af658756466854fc1a0b3edd91c1f37
This commit is contained in:
Alex Hunt
2023-09-22 04:43:11 -07:00
committed by Facebook GitHub Bot
parent 8c5340fd96
commit 3ef7de848d
3 changed files with 5 additions and 27 deletions
@@ -165,7 +165,10 @@ RCT_EXPORT_MODULE()
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;
}
@@ -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
@@ -51,10 +51,7 @@ static NSURL *getInspectorDeviceUrl(NSURL *bundleURL)
escapedDeviceName,
escapedAppName]];
}
static NSURL *getOpenUrlEndpoint(NSURL *bundleURL)
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/open-url", getServerHost(bundleURL)]];
}
@implementation RCTInspectorDevServerHelper
RCT_NOT_IMPLEMENTED(-(instancetype)init)
@@ -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]