以这种方式创建 React Native 应用程序有什么问题? [英] What is wrong with creating a React Native app this way?

查看:53
本文介绍了以这种方式创建 React Native 应用程序有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个基本的 React Native 应用程序.虽然我可以创建项目,但它不会在模拟器内运行.

I'm trying to create a basic React Native app. While I can create the project, it will not run inside the simulator.

应用加载后,它会立即退出.如果我删除 node_modules 并执行 npm install 以下载所有新模块,我将看到应用程序重新加载 Javascript.然后当它达到 100% 时,它立即再次退出.

After the app loads, it immediately quits. If I remove node_modules and do npm install to download all the modules fresh, I will see the app reload the Javascript. Then when it hits 100%, it immediately quits again.

我用来创建应用程序的步骤如下:

The steps I used to create the app are as follows:

$ react-native init demo1
$ cd demo1
$ react-native run-ios

字面意思就是这样.我正在使用以下版本的工具:

That's literally it. I'm using the following versions of tools:

$ node --version
v6.11.2
$ npm --version
3.10.10
$ react-native --version
react-native-cli: 2.0.1
react-native: 0.48.0

完整日志位于此处.我做错了什么?

The full log is here. What am I doing wrong?

进一步调查,结果发现 Xcode 项目失败并带有堆栈跟踪:

Investigating this more, it turns out the Xcode project fails with a stack trace:

2017-09-02 13:03:00.775 [info][tid:main][RCTCxxBridge.mm:188] Initializing <RCTCxxBridge: 0x6080001a2ae0> (parent: <RCTBridge: 0x6000000a1f80>, executor: (null))
2017-09-02 13:03:00.804 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-09-02 13:03:00.825 [info][tid:main][RCTRootView.m:301] Running application r1 ({
    initialProps =     {
    };
    rootTag = 1;
})
2017-09-02 13:03:00.960 r1[47802:5600672] -[NSTaggedPointerString unsignedIntValue]: unrecognized selector sent to instance 0xa313434323930327
2017-09-02 13:03:00.977 r1[47802:5600672] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString unsignedIntValue]: unrecognized selector sent to instance 0xa313434323930327'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e094b0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010cf4a141 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e104134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000010e01b840 ___forwarding___ + 1024
    4   CoreFoundation                      0x000000010e01b3b8 _CF_forwarding_prep_0 + 120
    5   r1                                  0x000000010c301394 -[RCTMultipartStreamReader emitProgress:contentLength:final:callback:] + 244
    6   r1                                  0x000000010c301b8a -[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:] + 1610
    7   r1                                  0x000000010c3514bc -[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:] + 444
    8   CFNetwork                           0x000000010daf4c51 __88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke + 51
    9   Foundation                          0x000000010ca543b7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
    10  Foundation                          0x000000010ca540bb -[NSBlockOperation main] + 101
    11  Foundation                          0x000000010ca52877 -[__NSOperationInternal _start:] + 627
    12  Foundation                          0x000000010ca4e5fc __NSOQSchedule_f + 198
    13  libdispatch.dylib                   0x0000000111d7605c _dispatch_client_callout + 8
    14  libdispatch.dylib                   0x0000000111d5494f _dispatch_queue_serial_drain + 221
    15  libdispatch.dylib                   0x0000000111d55669 _dispatch_queue_invoke + 1084
    16  libdispatch.dylib                   0x0000000111d57ec4 _dispatch_root_queue_drain + 634
    17  libdispatch.dylib                   0x0000000111d57bef _dispatch_worker_thread3 + 123
    18  libsystem_pthread.dylib             0x000000011210d5a2 _pthread_wqthread + 1299
    19  libsystem_pthread.dylib             0x000000011210d07d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是某种错误还是我做的?

Is this some sort of bug or is this something I did?

推荐答案

这似乎是 0.48 的问题.尝试使用 0.47.1,你应该没问题.

This seems to be a 0.48 issue. Try using 0.47.1 and you should be fine.

react-native init demo1 --version react-native@0.47.1

这篇关于以这种方式创建 React Native 应用程序有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆