在iOS分享扩展中使用React Native [英] Using React Native within an iOS share extension

查看:134
本文介绍了在iOS分享扩展中使用React Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跳出 facebook/react-native#1626 GitHub问题,我对在我发布了一个示例GitHub存储库,该问题进行了总结在下面.

I posted an example GitHub repo that demonstrates the problem, summarized below.

到目前为止,概念验证的设置非常简单,但是我感觉缺少了一些非常简单的东西.

So far the proof-of-concept setup is pretty straightforward, but I feel like I'm missing something very simple.

在我的react-native init脚手架Xcode项目中,我创建了一个新的共享扩展目标,并在其中链接了相应的React Native静态库(libReact.alibRCTWebSocket.a等).这使我们的项目编译为非常简单的ShareViewController ,是普通的'ol UIViewController.

In my react-native init scaffolded Xcode project I created a new Share Extension target, and within it linked the appropriate React Native static libraries (libReact.a, libRCTWebSocket.a, etc.). This gets our project compiling for a very simple ShareViewController that's a plain ‘ol UIViewController.

从另一个应用程序激活我的共享扩展程序后,我的ShareViewController已初始化,但立即崩溃并显示以下日志消息:

Upon activating my Share Extension from another app, my ShareViewController is initialized but immediately crashes with the following log messages:

2015-11-29 12:44:34.721 [warn][tid:com.facebook.React.JavaScript][RCTContextExecutor.m:129] 'undefined is not an object (evaluating \'RCTWebSocketModule.connect\')'
2015-11-29 12:44:34.726 ShareExtension[66473:2179009] -[RCTBatchedBridge redBox]: unrecognized selector sent to instance 0x7fb59d8ab200
2015-11-29 12:53:47.160 [warn][tid:com.facebook.React.JavaScript][RCTContextExecutor.m:129] 'Requiring module "InitializeJavaScriptAppEngine" which threw an exception'
2015-11-29 12:53:47.160 ShareExtension[66473:2179009] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTBatchedBridge redBox]: unrecognized selector sent to instance 0x7fb59d8ab200'

'Requiring module "InitializeJavaScriptAppEngine" which threw an exception'行看起来特别可疑,使我相信我在共享扩展中缺少一些基本的JavaScriptCore设置.好奇地想知道是否有任何明显的领域需要调查,或者是否有人解决了这个问题.谢谢!

The line 'Requiring module "InitializeJavaScriptAppEngine" which threw an exception' looks particularly suspicious, and leads me to believe that I'm missing some basic JavaScriptCore setup within the share extension. Curious to know if there are any obvious areas to investigate, or if anyone else has solved this problem. Thanks!

推荐答案

我遇到了相同的错误,并通过在我的应用扩展目标构建设置(其他链接器标记)中添加"-ObjC"来解决了该错误

I had the same error and fixed it by adding "-ObjC" in my app extension target build settings (Other linker flags)

这篇关于在iOS分享扩展中使用React Native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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