개발일지/React-Native

[React-Native] Fabric 모드 전환 시 Metro에 연결이 안되는 문제

Seobe95 2024. 10. 30. 04:46

Fabric 모드를 사용하고 iOS 실기기에서만 Metro에 연결되지 않는 문제가 발생했다.

 

여러가지 시도를 해봤지만, 해결된 방법은 RCTWebSocketExecutor.mm 파일의 localhost 부분을 본인의 ip로 변경하는 방법이었다.

 

- (void)setUp
{
  if (!_url) {
    NSInteger port = [[[_bridge bundleURL] port] integerValue] ?: RCT_METRO_PORT;
    NSString *host = [[_bridge bundleURL] host] ?: @"본인의 IP";
    NSString *URLString =
        [NSString stringWithFormat:@"http://%@:%lld/debugger-proxy?role=client", host, (long long)port];
    _url = [RCTConvert NSURL:URLString];
  }
 ...

 

참고 문서: https://reactnative.dev/docs/other-debugging-methods#debugging-on-a-physical-device