xcode React Native 无尽的Socket SO_ERROR流

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/54110128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:53:27  来源:igfitidea点击:

React Native endless stream of Socket SO_ERROR

xcodereact-nativereact-native-ios

提问by Karolis

I'm working on an existing React Native project and in XCode log output I get an endless stream of the following errors

我正在处理现有的 React Native 项目,在 XCode 日志输出中,我收到了源源不断的以下错误

2019-01-09 12:15:49.005630+0000 App [13746:3543026] [] nw_socket_handle_socket_event [C10.1:1] Socket SO_ERROR [61: Connection refused]
2019-01-09 12:15:49.016640+0000 App [13746:3543026] [] nw_socket_handle_socket_event [C10.2:1] Socket SO_ERROR [61: Connection refused]
2019-01-09 12:15:49.017800+0000 App [13746:3543010] [] nw_connection_get_connected_socket [C10] Client called nw_connection_get_connected_socket on unconnected nw_connection

How could I go about figuring out where this error is coming from? It doesn't seem to be affecting the app, but I would like to understand the issue. I suspect it's not the app's JavaScript code, but one of the pods being used:

我怎样才能弄清楚这个错误是从哪里来的?它似乎没有影响应用程序,但我想了解这个问题。我怀疑这不是应用程序的 JavaScript 代码,而是正在使用的 pod 之一:

pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Crash'

回答by David Leuliette

There is a thread on GitHub about that, it's related to iOS 12+ an Xcode 10+
https://github.com/facebook/react-native/issues/19573

GitHub 上有一个线程,它与 iOS 12+ 和 Xcode 10+
https://github.com/facebook/react-native/issues/19573 有关

I tried to change the buildSystem and it worked for me:

我尝试更改 buildSystem 并且它对我有用:

  • Go to File, then Project Settingsor Workspace Settings.
  • Select Legacy Build Systemfrom the Build System dropdown.
  • 转到File,然后Project SettingsWorkspace Settings
  • Legacy Build System从构建系统下拉列表中选择。

enter image description here

在此处输入图片说明

回答by curest0x1021

  1. To select XCode10 build system: In Xcode go to File-> Project Settings(or Workspace settings) -> Build system, in which change the New Build Systemto Legacy Build System.
  1. 要选择 XCode10 构建系统:在 Xcode 中转到File-> Project Settings(或Workspace settings)-> Build system,其中New Build SystemLegacy Build System.

enter image description here

在此处输入图片说明

  1. Temporary fix: Edit Scheme=> Run=> Environment Variables=> Add OS_ACTIVITY_MODE:disable in the XCode.
  1. 临时修复: Edit Scheme=> Run=> Environment Variables=>OS_ACTIVITY_MODE在 XCode 中添加:disable。

Note: This works fine, but keep in mind that it also suppresses all NSLog output you may need for debugging.

注意:这工作正常,但请记住,它还会抑制调试可能需要的所有 NSLog 输出。

enter image description here

在此处输入图片说明

回答by Fiona.W

If you run your app on ios: 1. Go to ios/APP_NAME/Info.plist 2. Add these two entries to the Info.plist:

如果您在 ios 上运行您的应用程序: 1. 转到 ios/APP_NAME/Info.plist 2. 将这两个条目添加到 Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We'll show you things near you in the app.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We'll show you things near you in the app. With "always" access, we'll
    also send you notifications when you're near something interesting.</string>