huo*_*ird 5 reactjs react-native
非常高兴在2015年F8上看到Facebook开源React Native.虽然它们提供react-native-cli了生成一个空的React Native项目,但我仍然不知道如何将React Native集成到我当前使用Xcode工作区和CocoaPods的项目中.
您可以查看此演示: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安装命令行工具.
然后进入你的Xcode项目目录,创建package.json文件.内容如下:
然后你npm install在终端运行.过了一会你会找到一个目录node_modules
下一步是运行pod init.Podfile将创建.所以只需打开并配置它就像流动一样
您应该注意在Podfile中配置的React路径.
然后跑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 的完整分步指南如下:https: //facebook.github.io/react-native/docs/integration-with-existing-apps.html
| 归档时间: |
|
| 查看次数: |
4243 次 |
| 最近记录: |