Mac安装ReactNative

来源:互联网 发布:爬虫软件有哪些 编辑:程序博客网 时间:2024/04/30 21:25

需求

  1. OS X – 现在这个仓库只包含 iOS 实现,且 Xcode 只能在 Mac 上运行。
  2. 不知道 Xcode 吗?从 Mac App Store 上 Homebrew。
  3. brew install node。不知道 npm
  4. brew install --HEAD watchman。我们建议安装 flow。

快速开始

  • npm install -g react-native-cli
  • react-native init AwesomeProject

在新建的文件夹 AwesomeProject/ 中

  • 打开 AwesomeProject.xcodeproj,点击 Xcode 中的运行
  • 打开你选择的文本编辑器中的 index.ios.js,并且对一些行进行编辑。
  • 在你的 iOS 模拟器中点击 cmd + R(两次),看看有什么变化!

恭喜!你刚刚成功运行并修改了你的第一个 React Native 应用


mac 下更新 .bash_profile 文件

1、打开terminal(终端)

2、cd ~ ( 进入当前用户的home目录)

3、open .bash_profile (打开.bash_profile文件,如果文件不存在就  创建文件:touch .bash_profile  编辑文件:open -e .bash_profile)

4、直接更改弹出的.bash_profile文件内容

You should create NVM's working directory if it doesn't exist:

  mkdir ~/.nvm

Add the following to ~/.bash_profile or your desired shell

configuration file:(.bash_profile 加入以下代码)

  export NVM_DIR=~/.nvm

  . $(brew --prefix nvm)/nvm.sh

5、command + s 保存文件,然后关闭

6、在terminal(终端)中输入 source .bash_profile (使用刚才更新之后的内容)

0 0