React Native Mac 环境搭建 - Go语言中文社区

React Native Mac 环境搭建


打开终端:

brew install node

看到

这里写图片描述

输入npm -v 后查看安装成功的node.js

然后执行
npm install -g react-native-cli

安装react-native 命令行工具

react-native –help

可以查看命令行工具支持的命令

接下来安装Xcode
之后安装Android Studio

然后初始化一个应用

react-native init FirstApp

如果收到-bash:react-native:command not found

则输入
npm list -g | head -n 1
得到
/usr/local/Cellar/node/8.1.4/lib
得到react native 安装的路径

open .bash_profile
添加
export PATH=”/usr/local/Cellar/node/8.1.4/bin:$PATH”

source .bash_profile

再次执行

react-native init FirstApp

则看到成功创建第一个apk

用命令后运行iOS项目

cd FirstApp
执行
react-native run-ios

如果遇到错误:
xcrun: error: unable to find utility “instruments”, not a developer tool or in PATH
则要执行
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
再次运行遇到错误:

Installing build/Build/Products/Debug-iphonesimulator/MyFirsrRNapp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, “:CFBundleIdentifier”, Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/MyFirsrRNapp.app/Info.plist
Print: Entry, “:CFBundleIdentifier”, Does Not Exist

修改方法:
react-native 中文参考网有解释:
http://reactnative.cn/docs/0.49/getting-started.html#content

http://blog.csdn.net/s8460049/article/details/73330784

首先要启动一个android模拟器
react-native run-android

分别运行俩个平台的项目

要安装好各自的模拟器

可以通过Xcode 运行iOS项目,双击
FirstApp.xcodeproj
点击运行按钮
通过a s 运行android项目,open新的项目
启动模拟器
点击运行

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/mingtiannihao623/article/details/75579360
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-01 21:55:10
  • 阅读 ( 1408 )
  • 分类:Go环境配置

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢