This is the first day of my participation in the August More text Challenge. For details, see: August More Text Challenge

preface

Recently changed a new computer, need to reconfigure a development environment, so take this opportunity to record the installation process of CocoaPods, convenient to re-install later, you can follow the installation process to do. At the same time, I also hope to help people who have the need to install CocoaPods.

The installation process

1. Install HomeBrew

To avoid errors during installation, let’s download HomeBrew.

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

2. Install the RVM and upgrade the Ruby environment

Cocopods requires a version of Ruby, so we can upgrade ruby to a higher version. Here, we first download RVM and use RVM (Ruby Version Manager) to manage and switch multi-version Ruby environment.

curl -L get.rvm.io | bash -s stable

# enable RVM
source ~/.rvm/scripts/rvm

Check the RVM version to see if the installation is successful
rvm -v
Copy the code

3. Install ruby

The next step is to install the specified version of Ruby using RVM.

# View the installable Ruby versions
rvm list known

# Select a relatively high ruby version to installRVM install 2.7Check the installed Version of Ruby
rvm list
Copy the code

4. Set the default ruby version (optional)

When we have multiple versions of Ruby installed via RVM, we can set a default version of Ruby. This step is optional if you have only one version of Ruby installed.

RVM use 2.7.2 - defaultCopy the code

5. Replace the Ruby image source

In order to perform the normal download operation, we will remove the default source and add a mirror source that can be accessed normally in China: gems.ruby-china.com.

gem sources --remove  https://rubygems.org/

gem sources -a https://gems.ruby-china.com

# Confirm that the download source has been replaced successfully
gem sources -l
Copy the code

PS: In our mirror source switch and other operations, you can copy to the browser to access, to ensure that the mirror source to switch to is normal access.

6. Install CocoaPods

Start installing CocoaPods. The -v parameter is used to specify the version

sudo gem install -n /usr/local/ bin 1.10.1 cocoapods - vCopy the code

Check to see if the installation was successful by looking at the Cocoapods version. If the console outputs the version number successfully, the installation process is basically ok.

pod --version
Copy the code

7. Test CocoaPods usage

After the installation is complete, you still need to use the test. Let’s go to the project directory and run the following command to generate the podfile.

pod init
Copy the code

Run install to manage the package for the project

pod install
Copy the code

So far, the installation of Cocoapods is completed, may be due to the network environment is very good reasons, this time did not encounter any problems, I hope you can install when everything goes well.

The resources

  • zhuanlan.zhihu.com/p/111014448
  • www.jianshu.com/p/f43b5964f…
  • www.jianshu.com/p/3c1f439ba…