post:增加React Native相关文档,但待持续更新。
This commit is contained in:
parent
cee34bea5f
commit
0e89765458
40
source/_posts/react-native-traps.md
Normal file
40
source/_posts/react-native-traps.md
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
title: React Native踩坑集锦
|
||||||
|
tags:
|
||||||
|
- 前端
|
||||||
|
- Javascript
|
||||||
|
- Typescript
|
||||||
|
- React Native
|
||||||
|
categories:
|
||||||
|
- - 前端
|
||||||
|
- React Native
|
||||||
|
keywords: 'react,react native,typescript,javascript,cocoapods'
|
||||||
|
date: 2021-06-30 06:32:14
|
||||||
|
---
|
||||||
|
|
||||||
|
React Native是一个利用前端技术实现的移动端框架,所以在开发环境构建和应用开发过程中,常常需要同时用到前端和移动端的技术,这也就导致了React Native在使用的时候也会同时踩前端和移动端的两重坑。这里对已经踩过的坑做一个记录,方便再碰上以后能跳过去。<!-- more -->
|
||||||
|
|
||||||
|
## 更换CocoaPods的镜像
|
||||||
|
|
||||||
|
在使用`react-native-cli`构建React Native应用的时候,会使用到用于iOS的CocoaPods框架,这个框架在不使用镜像的时候常常会导致应用的iOS部分创建失败。要解决这个问题,可以将CocoaPods的镜像改为清华Tuna镜像。
|
||||||
|
|
||||||
|
!!! caution ""
|
||||||
|
一般CocoaPods出问题最常见的提示就是:`[!] CocoaPods could not find compatible versions for pod`。
|
||||||
|
|
||||||
|
由于新版的React Native(0.60以上版本)使用的一般都是新版的CocoaPods,所以这里不再记录对于旧版CocoaPods切换镜像的操作了。
|
||||||
|
|
||||||
|
要切换CocoaPods的镜像,需要按顺序执行以下几条命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/.cocoapods/repos
|
||||||
|
pod repo remove master
|
||||||
|
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
|
||||||
|
```
|
||||||
|
|
||||||
|
然后再回到应用项目目录中的`ios`目录中执行`pod install --repo-update`。执行结束后,再将项目中的`Podfile`顶部添加以下一行内容。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
|
||||||
|
```
|
||||||
|
|
||||||
|
即可完成CocoaPods镜像的切换。
|
Loading…
Reference in New Issue
Block a user