[iOS真机运行输出]Could not connect to

2016-01-11  本文已影响4595人  laznrbfe

RN0.30.0+不需要修改IP地址

Xcode 打印

Jan 11 17:47:48  AwesomeProject[5347] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 11 17:47:48  AwesomeProject[5347] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jan 11 17:47:48  AwesomeProject[5347] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2016-01-11 17:47:48.725 [error][tid:main] Could not connect to development server.

Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate

URL: http://localhost:8081/index.ios.bundle?platform=ios&dev=true

解决:

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

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

也许你会遇到另外一个问题

WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused"

请跳转到http://www.jianshu.com/p/2c5e738cecca 查看(因为本人这两个问题不是同时出现,所以分开写)。

参考

Running On Device
Test your React Native app on your iPhone or iPad

上一篇下一篇

猜你喜欢

热点阅读