我的工程创建时间是2019.7.11号下午   :首先看一下最后我的工程的package.json各个包的版本:

{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.8",
"react-native-gesture-handler": "^1.3.0",
"react-navigation": "^3.11.0"
},
"devDependencies": {
"@babel/core": "^7.5.4",
"@babel/runtime": "^7.5.4",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}

1.安装依赖

brew install node    brew install watchman    注意 node>10

安装yarn

npm install -g yarn react-native-cli

安装完 yarn 后同理也要设置镜像源:

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
 
在Appstore下载Xcode  版本>10
React Native 目前需要Xcode 9.4 或更高版本。你可以通过 App Store 或是到Apple 开发者官网上下载。
这一步骤会同时安装 Xcode IDE、Xcode 的命令行工具和 iOS 模拟器。
创建新项目
安装第三方依赖,再http://bbs.reactnative.cn/topic/4301/ios-rn-0-45以上版本所需的第三方编译库-boost等
选择最高版本,复制到.rncahce文件夹下
需要安装到根目录下的.rncache文件夹 所以执行一下操作,

hewenkedeMacBook-Pro:AwesomeProject hewenke$ cd ~

hewenkedeMacBook-Pro:~ hewenke$ mkdir .rncache

hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/boost_1_63_0.tar.gz ~/.rncache/

hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/double-conversion-1.1.5.tar.gz ~/.rncache/

hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/double-conversion-1.1.6.tar.gz ~/.rncache/

hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/folly-2018.10.22.00.tar.gz ~/.rncache/

hewenkedeMacBook-Pro:~ hewenke$ cp ~/Downloads/glog-0.3.5.tar.gz ~/.rncache/

hewenkedeMacBook-Pro:~ hewenke$ cd .rncache

hewenkedeMacBook-Pro:.rncache hewenke$ ls

boost_1_63_0.tar.gz folly-2018.10.22.00.tar.gz

double-conversion-1.1.5.tar.gz glog-0.3.5.tar.gz

double-conversion-1.1.6.tar.gz

hewenkedeMacBook-Pro:.rncache hewenke$ rm double-conversion-1.1.5.tar.gz

hewenkedeMacBook-Pro:.rncache hewenke$ ls

boost_1_63_0.tar.gz folly-2018.10.22.00.tar.gz

double-conversion-1.1.6.tar.gz glog-0.3.5.tar.gz

安装完第三方依赖,就可以创建新项目
react-native init AwesomeProject
初始化结束以后cd AwesomeProject && react-native run-ios
就可以启动项目
===>注意事项 不要初始化0.44版本的项目。问题太多。
 
 
app.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/ import React, {Fragment} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native'; import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen'; const App = () => {
return (
<Fragment>
<StatusBar barStyle="dark-content" style={{backgroundColor:'#99cc61'}}/>
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</Fragment>
);
}; const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
}); export default App;

页面就可以正常出来。

按照官网   需要路由,但是后期如果使用路由组件react-navigation 和react-native-gesture-handler 安装这两个库以后,react-native>=0.6就会出错

这两个的安装按照  官网来 连接  https://reactnavigation.org/docs/zh-Hans/getting-started.html#%E5%AE%89%E8%A3%85

这个时候需要吧版本降到0.6一下 比如0.59.8,我安装的是0.59.8  react-native  init demo --version 0.59.8 重新新建一个工程, 完了执行react-native run-ios  就可以运行了,这个编译时间比教长,就可以正常使用路由了

Mac 安装react-native 环境踩坑记的更多相关文章

  1. 史上最全Windows版本搭建安装React Native环境配置

    史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...

  2. 史上最详细Windows版本搭建安装React Native环境配置 转载,比官网的靠谱亲测可用

    史上最详细Windows版本搭建安装React Native环境配置   2016/01/29 |  React Native技术文章 |  Sky丶清|  95条评论 |  33530 views ...

  3. Windows版本搭建安装React Native环境配置

    1 安装Chocolatey 打开cmd黑窗口 @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-obje ...

  4. react-native学习笔记--史上最详细Windows版本搭建安装React Native环境配置

    参考:http://www.lcode.org/react-native/ React native中文网:http://reactnative.cn/docs/0.23/android-setup. ...

  5. Windows版本搭建安装React Native环境配置及相关问题

    此文档整理参考地址: http://www.lcode.org/%E5%8F%B2%E4%B8%8A%E6%9C%80%E8%AF%A6%E7%BB%86windows%E7%89%88%E6%9C% ...

  6. 史上最详细Windows版本搭建安装React Native环境配置

    说在前面的话: 感谢同事金晓冰倾情奉献本环境搭建教程 之前我们已经讲解了React Native的OS X系统的环境搭建以及配置,鉴于各大群里有很多人反应在Windows环境搭建出现各种问题,今天就特 ...

  7. Mac 配置 React Native 环境

    OSX系统,这里假定你是iOS开发人员 Homebrew 是需要的,只有安装了Homebrew才能继续安装watchman和flow 安装 Node.js 4.0 或者更新的版本. 使用 Homebr ...

  8. 初识React Native,踩坑之旅....

    开启Genymotion Android模拟器后 1.运行“react-native run-android”报端口冲突....解决方法: 2.运行“react-native run-android” ...

  9. ThingsBoard安装编译搭建环境踩坑记录

    1.首先从github拉下来项目,我们采用源码编译的方式部署 git clone https://github.com/thingsboard/thingsboard.git 2.切换分支 git c ...

随机推荐

  1. rocketmq单点部署

    下载地址:https://github.com/alibaba/RocketMQ 转载请注明来源:http://blog.csdn.net/loongshawn/article/details/510 ...

  2. Nginx功能模块汇总

    主要文档 Nginx功能概述.为什么选择Nginx.Nginx安装.常见问题(FAQ).配置符号参考.调试 nginx.优化 Nginx.运行和控制Nginx 核心模块 Nginx事件模块.Nginx ...

  3. dubbo系列学习好文章

    1. dubbo入门学习(一)-----分布式基础理论.架构发展以及rpc.dubbo核心概念 https://www.cnblogs.com/alimayun/p/10982650.html 2. ...

  4. CompletableFuture提高你并发编程能力

    思考:如果有两个顺序执行耗时的方法,你该怎么做??? 例如: public void doHousework() { //烧水 doWater(); //扫地 doFloor(); } 没错,聪明如我 ...

  5. PHP CURL 模拟form表单上传遇到的小坑

    1:引用的时候 $parans ['img']=new \CURLFile($param); 传入的文件 在PHP版本5.5以上记得new CURLFile 不然会上传不成功 /** * http p ...

  6. Linux NIO 系列(04-2) poll

    目录 一.select 和 poll 比较 二.poll API 附1:linux 每个进程IO限制 附2:poll 网络编程 Linux NIO 系列(04-2) poll Netty 系列目录(h ...

  7. uvloop官网翻译

    魔术堆栈 uvloop:快速的Python网络连接 作者Yury Selivanov @ 1st1 2016年5月3日 TL; DR asyncio是Python标准库附带的异步I / O框架.在此博 ...

  8. springMVC 框架的xml配置文件的说明

    springMVC框架xml文件配置的说明,直接上代码: 我们介绍四个xml文件配置以及xml内容的理解:application.xml.spring-mvc.xml.pom.xml 和 web.xm ...

  9. 【牛客网-剑指offer】跳台阶

    题目: 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果). 考点: 递归和循环 思路: 1)利用二叉树,左孩子为跳一级,右孩子为跳两 ...

  10. Fastjson <= 1.2.47 远程命令执行漏洞

    一.漏洞利用过程 查看java版本:java -version jdk版本大1.8 openjdk versin "1.8.0_222" 下载漏洞利用文件:git clone ht ...