问题
I'm working on an existing React Native project and in XCode log output I get an endless stream of the following errors
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:
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'Firebase/Crash'
回答1:
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
I tried to change the buildSystem and it worked for me:
- Go to
File
, thenProject Settings
orWorkspace Settings
. - Select
Legacy Build System
from the Build System dropdown.
回答2:
- To select XCode10 build system:
In Xcode go to
File
->Project Settings
(orWorkspace settings
) ->Build system
, in which change theNew Build System
toLegacy Build System
.
enter image description here
- Temporary fix:
Edit Scheme
=>Run
=>Environment Variables
=> AddOS_ACTIVITY_MODE
:disable in the XCode.
Note: This works fine, but keep in mind that it also suppresses all NSLog output you may need for debugging.
enter image description here
回答3:
If you run your app on ios: 1. Go to ios/APP_NAME/Info.plist 2. Add these two entries to the 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>
来源:https://stackoverflow.com/questions/54110128/react-native-endless-stream-of-socket-so-error