undefined不是对象(评估'RCTWebSockerManager.connect') - React Native

klv*_*lvs 5 reactjs react-native

我一直在关注如何将现有应用程序与native native集成的指南.http://facebook.github.io/react-native/docs/embedded-app-ios.html#content

根据我们的IOS人员的建议,我对IOS方面的一些自由行动.当我的视图加载时,我得到一个带有堆栈跟踪的红色错误屏幕:

http://puu.sh/jRgDg/b844f139b2.png

(对不起,没有足够的声誉来发布图片.文字包括在下面.)

2015-08-27 22:19:37.739 [error][tid:com.facebook.React.JavaScript] 'Warning: Native component for "RCTImageView" does not exist' 2015-08-27 22:19:37.851 [info][tid:com.facebook.React.JavaScript] 'Running application "SimpleApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' 2015-08-27 22:19:37.856 [error][tid:com.facebook.React.JavaScript] 'Error: undefined is not an object (evaluating \'RCTWebSocketManager.connect\') stack: connectToSocketImpl index.ios.bundle:14464 WebSocketBase index.ios.bundle:14587 WebSocket index.ios.bundle:14458 setupDevtools index.ios.bundle:46060 renderApplication index.ios.bundle:44403 run index.ios.bundle:44295 runApplication index.ios.bundle:44323 __callFunction index.ios.bundle:5552 <unknown> index.ios.bundle:5488 guard index.ios.bundle:5441 <unknown> index.ios.bundle:5488 <unknown> index.ios.bundle:5485 perform index.ios.bundle:7033 batchedUpdates index.ios.bundle:16454 batchedUpdates index.ios.bundle:6336 <unknown> index.ios.bundle:5484 guard index.ios.bundle:5441 processBatch index.ios.bundle:5483 URL: http://192.168.1.70:8081/index.ios.bundle line: 14464 message: undefined is not an object (evaluating \'RCTWebSocketManager.connect\')'

这是我的Podfile:

    pod 'FBSDKShareKit'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'React'
pod 'React/RCTText'
Run Code Online (Sandbox Code Playgroud)

("URL:"已更改为手动而非本地主机,但在浏览器中响应相同.)

当我跑:

(JS_DIR=`pwd`/ReactComponent; cd Pods/React; npm run start -- --root $JS_DIR)
Run Code Online (Sandbox Code Playgroud)

一切都运行良好的日志yeilding:

    [22:32:15] <START> fs crawl
[22:32:16] <END>   fs crawl (744ms)
[22:32:16] <START> Building in-memory fs
[22:32:16] <END>   Building in-memory fs (454ms)
[22:32:16] <START> Building in-memory fs
[22:32:17] <END>   Building in-memory fs (242ms)
[22:32:17] <START> Building Haste Map
[22:32:17] <START> Building (deprecated) Asset Map
[22:32:17] <END>   Building (deprecated) Asset Map (75ms)
[22:32:17] <END>   Building Haste Map (836ms)
Run Code Online (Sandbox Code Playgroud)

一旦我在xcode ios-simulator中启动项目,我就得到了前面提到的堆栈跟踪.我可以包含我的目标c代码,如果它有用,但我省略了以防止混乱,因为它似乎是反应依赖的问题.

谢谢!任何帮助表示赞赏.

klv*_*lvs 4

所以我想通了。如果您遇到此问题,请将我的 podfile 修复为有效。删除 Pods/ 目录,然后使用以下 podfile 再次运行 pod install。重新启动开发服务器也是一种好的措施。

pod 'FBSDKShareKit' pod 'FBSDKCoreKit' pod 'FBSDKLoginKit' pod 'React' pod 'React', :subspecs => [ 'RCTText', 'RCTImage', 'RCTNetwork', 'RCTWebSocket' ]