React Native在iOS真机运行的错误:Could not connect to development server.

前端之家收集整理的这篇文章主要介绍了React Native在iOS真机运行的错误:Could not connect to development server.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、URL地址设置

问题:

  1. Could not connect to development server.
  2.  
  3. Ensure the following:
  4. - Node server is running and available on the same network - run 'npm start' from react-native root
  5. - Node server URL is correctly set in AppDelegate
  6.  
  7. URL: http://localhost:8081/index.ios.bundle?platform=ios&dev=true
  8. 2016-08-29 17:52:29.307 [error][tid:main][RCTWebSocketManager.m:84] WebSocket connection Failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"


解决:

AppDelegate.m文件中,把一下代码中的localhost改为你电脑的IP地址,并且保证连接的是同一个网络(例如:连接同一个路由的网络)。

  1. jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

2、HTTP设置

  1. 2016-08-29 18:01:20.273 AwesomeProject[688:263429] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
  2. 2016-08-29 18:01:20.316 [fatal][tid:main] Could not connect to development server.
  3.  
  4. Ensure the following:
  5. - Node server is running and available on the same network - run 'npm start' from react-native root
  6. - Node server URL is correctly set in AppDelegate
  7.  
  8. URL: http://10.240.139.46:8081/index.ios.bundle?platform=ios&dev=true

开启ATS即可

猜你在找的React相关文章