当前位置:网站首页>Cocoapods installation in 2021
Cocoapods installation in 2021
2022-06-25 16:10:00 【super_ man_ Breezy】
Text
I installed it many times CocoaPod, I have encountered all kinds of annoying problems , It also makes me learn a lot from the constant exploration , To sum up , For your study , The following process has been tested by my new machine , A smooth journey without any mistakes ( Please strictly follow the following methods ), If the network is not good, the download may be interrupted and an error may occur , Just execute the command again .
CocoaPods brief introduction :
CocoaPods It's a use. Ruby Written 、 Responsible for managing the iOS Tools of the third party open source library in the project ,CocoaPods What we can focus on 、 Unified management of third-party open source libraries , Save us time setting up and updating third-party open source libraries .
CocoaPods install :
Now the installation begins CocoaPods, There may be a blank space in the middle of the command , It is recommended to copy and paste directly ;
because Mac The computer comes with Ruby Environmental Science , We just need to open the terminal and start . But because by default we mac System native Ruby The environment version is relatively low ( Probably 2.0.0 Or other higher versions ), But now install CocoaPods need 2.2.2 Version and above , So we will upgrade directly regardless of the three seven twenty-one ruby.
Open the terminal :>_
1、 View the current Ruby edition
ruby -v
2、 upgrade Ruby Environmental Science , Installation is required first rvm( The first step is to download something and wait about two minutes )
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
3、 see rvm edition
rvm -v
It is shown as follows ( Or other versions )
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
4、 List ruby Installable version information
rvm list known
It is shown as follows
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.7]
[ruby-]2.4[.4]
[ruby-]2.5[.1]
.....
[ruby-]2.6[.3] // That's the point That's the point That's the point
[ruby-]2.7[.0-preview1] // The beta
ruby-head
.....
5、 To install a ruby edition ( So here's what I chose 2.5.1 edition , Of course, you can choose other )
rvm install 2.6.3
// Be careful : Press twice during installation Enter key , After the second press, you need to enter the computer access password ( invisible , Just type in );
// If your computer is not installed Xcode and Command Line Tools for Xcode as well as Homebrew Will automatically download and install , It is recommended to install these three in advance .
Many friends here will encounter errors , Most of them are not installed Homebrew cause , So it's better to install it in advance
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
6、 Set to default version
rvm use 2.6.3 --default
7、 Replace source
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
8、 To verify your Ruby Mirroring is and only ruby-china, Execute the following command to view
gem sources -l
If the following results are correct , If there are other problems, please solve them by Baidu
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
9、 At this time, the installation started CocoaPods
sudo gem install -n /usr/local/bin cocoapods
10、 If more than one is installed Xcode Use the following command to select ( Generally, you need to select the nearest Xcode edition )
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
11、 Install local libraries
pod setup
12、 After executing the above order
Setting up CocoaPods master repo
$ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1879515, done.
remote: Compressing objects: 100% (321/321), done.
Receiving objects: 21% (404525/1879515), 73.70 MiB | 22.00 KiB/
Then there was the long wait , Of course , When the network is good, it will be faster
The key is coming. , Be careful
the latest version MacOS Catalina The system command line executes pod setup The order ends directly ;
Don't worry , We manually install the local library , Absolutely fast
The command line does the following
git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
Be careful :
Be careful :
Be careful :
Important things to reiterate :
Using this command to execute and wait for a period of time is likely to fail ,
The reason is basically network problems ,
Please don't worry ,
According to the many tests of myself and my friends ,
Only when using mobile phone network or in the early morning, the network speed will be ideal
( About a few minutes OK, In other cases, even if your network bandwidth is good, it is useless )
If you can't stay up at night , I can't get up in the morning , Mobile traffic is gone again , Then look down ! Ah .......
Or use the following , Domestic mirror , The speed is just
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
The directory structure is shown in the figure below , If not, move it manually
Snip20191011_2.png
If not
// Install the latest version cocoapods
sudo gem install cocoapods --pre
// Remove local master
sudo rm -fr ~/.cocoapods/repos/master
// Remove local cache
sudo rm -fr ~/Library/Caches/CocoaPods/
// again setup, If it is very slow, you can use the problem 1 Solutions for (git clone)
pod setup --verbose
// remove trunk
pod repo remove trunk
You can refer to :CocoaPods| Installation process and use (macOS-Mojave)
If the installation fails all the time, please refer to here
The following paragraph omits , Look directly at The first 13 Step :
To view the file download progress, you can open another terminal window ( Shortcut key : Select the terminal and press Command+N Composite key ), Enter the following two lines to execute
cd ~/.cocoapods
du -sh *
perform du -sh * After that, the downloaded file size will be displayed , It can be executed multiple times to monitor the download progress , If there was a file size before , Later it became 0 了 , It could be a network problem , The download has been interrupted , You need to end the command and execute it again pod setup
13、 After the download and installation is completed, execute the following command to check whether it is available ( The first use may take a while )
pod search AFNetworking
14、CocoaPods Specific use of
Create a new one Xcode engineering , Use terminal cd Go to the project directory
establish Podfile file :
pod init
Then you can see a in the project directory Podfile file
open Podfile file :
open Podfile
add to :
pod 'AFNetworking'
Exit after saving
Start the download :
pod install
I make mistakes here for the first time , Just... Again ( Look at character ) Just do it , It may be the network or other reasons .
边栏推荐
- What exactly is a handler
- Resolve the format conflict between formatted document and eslint
- Rxjs TakeUntil 操作符的学习笔记
- Mixed density network (MDN) for multiple regression explanation and code example
- Converting cifar10 datasets
- Function and implementation of closures
- Vscode有什么好用的插件?
- 面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
- Alvaria announces Jeff cotten, a veteran of the customer experience industry, as its new CEO
- mysql整体架构和语句的执行流程
猜你喜欢

Prototype chain analysis

DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection翻译

分享自己平时使用的socket多客户端通信的代码技术点和软件使用

Educational administration system development (php+mysql)
What is session? How is it different from cookies?
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge

GridLayout evenly allocate space

Don't underestimate the integral mall, its role can be great!
Check whether the port number is occupied

Asynchronous processing of error prone points
随机推荐
Uniapp converts graphic verification codes in the form of file streams into images
分享自己平时使用的socket多客户端通信的代码技术点和软件使用
数据存储和传输文件之XML使用和解析详解
镁光256Gb NAND Flash芯片介绍
js 给元素添加自定义属性
Bugly hot update usage
AspNetCore&云效Flow持续集成
Constructor Pattern
Golang uses Mongo driver operation - increase (Advanced)
What exactly is a handler
商城风格也可以很多变,DIY了解一下!
Jz-065 path in matrix
Several ways of SQL optimization
leetcode-8. 字符串转换整数 (atoi)
What is session? How is it different from cookies?
Power representation in go language
[issue 24] one year experience of golang to develop futu
Servlet详解
[problem solving] dialogfragment can not be attached to a container view
f_read 函数[通俗易懂]