非常高兴地看到Facebook的开源阵营的本土F8 2015年虽然他们提供 react-native-cli 生成一个空的阵营本地项目,我仍然不知道如何整合作出反应原产于它使用Xcode的工作空间和的CocoaPods我当前的项目 .
react-native-cli
有关如何在现有项目中使用React Native的完整分步指南,请访问:https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
你可以看一下这个演示:https://github.com/dsibiski/react-native-hybrid-app-examples
在开始使用本机反应之前,您应该阅读他们的文档:http://facebook.github.io/react-native/docs/getting-started.html
然后我们应该运行 npm install -g react-native-cli 来安装命令行工具 .
npm install -g react-native-cli
下一步是安装cocoapods .
然后进入你的Xcode项目目录,创建 package.json 文件 . 内容如下:
package.json
然后在终端中运行 npm install . 片刻之后,您将找到一个目录 node_modules 下一步是运行 pod init . 将创建 Podfile . 所以只需打开并配置它就像流动一样
npm install
node_modules
pod init
Podfile
然后你的Podfile就像这样
您应该注意已在Podfile中配置的React路径 .
然后运行 pod install . 你会得到工作区 .
pod install
您还需要服务器或脱机捆绑包,请将其签出
https://facebook.github.io/react-native/docs/running-on-device-ios.html
https://github.com/facebook/react-native/issues/240
你之后可能遇到的一些问题:
1.检测到命名冲突:
https://github.com/facebook/react-native/issues/3440
2.不适用于ios(App Extension).....
在Podfile中添加代码
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' end end end
希望它有用:)
React Native可作为CocoaPod使用,并作为React Native的一部分进行分发(在通过npm安装的 node_modules 内) .
要与现有应用程序集成非常简单,只需在视图层次结构中的任何位置添加 RCTRootView 实例,React Native应用程序就可以在其中运行 . 见this guide .
RCTRootView
3 回答
有关如何在现有项目中使用React Native的完整分步指南,请访问:https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
你可以看一下这个演示:https://github.com/dsibiski/react-native-hybrid-app-examples
在开始使用本机反应之前,您应该阅读他们的文档:http://facebook.github.io/react-native/docs/getting-started.html
然后我们应该运行
npm install -g react-native-cli
来安装命令行工具 .下一步是安装cocoapods .
然后进入你的Xcode项目目录,创建
package.json
文件 . 内容如下:然后在终端中运行
npm install
. 片刻之后,您将找到一个目录node_modules
下一步是运行pod init
. 将创建Podfile
. 所以只需打开并配置它就像流动一样然后你的Podfile就像这样
然后运行
pod install
. 你会得到工作区 .您还需要服务器或脱机捆绑包,请将其签出
https://facebook.github.io/react-native/docs/running-on-device-ios.html
https://github.com/facebook/react-native/issues/240
你之后可能遇到的一些问题:
1.检测到命名冲突:
https://github.com/facebook/react-native/issues/3440
2.不适用于ios(App Extension).....
在Podfile中添加代码
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' end end end
希望它有用:)
React Native可作为CocoaPod使用,并作为React Native的一部分进行分发(在通过npm安装的
node_modules
内) .要与现有应用程序集成非常简单,只需在视图层次结构中的任何位置添加
RCTRootView
实例,React Native应用程序就可以在其中运行 . 见this guide .