I recently reinstalled cocoapods, the reference installation process: http://blog.csdn.net/showhilllee/article/details/38398119/
But the current cocoapods is compared with the previous one. There are many different places. After struggling for 2 days, I finally got it. Record it now.
1. First check whether ruby is the latest version. Ruby is installed through rvm, so you need to install rvm first and then check whether ruby is the latest (judging by viewing the list of ruby versions), enter the following commands in the terminal needs:
(1) Install RVM.RVM: Ruby Version Manager, Ruby version Manager, including Ruby version management and Gem library management (gemset)
curl -L get.rvm.io | bash -s stable
After waiting for a while, you can successfully install RVM
source ~/.bashrc
source ~/.bash_profile
Test whether Install normal
rvm -v
(2) Upgrade Ruby with RVM #Check
the current ruby version
$ ruby -v
ruby 2.0.0 #List known
ruby versions -- find the latest version install
$ rvm list known #Install
ruby 2.6.4
$ rvm install 2.6.4
2. Replace the Ruby image -- the Taobao image (https://ruby.taobao.org/ ) is no longer available. Official needs FQ.
So we now use the command line required by the latest supported ruby mirror (https://gems.ruby-china.org/) :
gem sources --remove https://rubygems.org/
gem sources -a https://gems .ruby-china.org/
gem sources -l (used to check the success of using the replacement mirror location)
appears to indicate success.
3. Download and install CocoaPods Enter
in the command line:
Install: sudo gem install cocoapods
Update: sudo gem update cocoapods
will be fine here soon. . . The online tutorial says that this completes the installation. . But I gave it a try and searched directly. Enter: pod search AFNetworking in the terminal. The "Setting up CocoaPods master repo" prompt will appear, and it has not been moved for a long time. It is said on the Internet that it is because there is no FQ. But we have changed the bury image, why is it still like this? . Another reason is because the download is in the background and the download has not been completed, so this happens.
I have been waiting here for a long time. By opening a new terminal window, enter the "cd ~/.cocoapods/" command line to jump to the cocoapods folder, and execute "du -sh *" to view the size of the folder. Found is always 0. About to collapse. Back from get off work to rest.
the next day. I start all over again. First update ruby to the latest (the above method), update the gem to the latest, and update the cocoapods to the latest. When updating cocoapods to the latest, it is found that "pod setup" needs to be executed, but when executing this, it will always be "Setting up CocoaPods master repo", but the view size is still 0. In addition, this new error occurs (I'm ecstatic to find this, at least it's not so monotonous, and maybe it's a breakthrough):
[!] An error occurred while performing `git pull` on repo `master`.
[! ] /usr/bin/git pull --ff-only
This error should mean that there is a problem with this node. Just look for information again, and then try to delete the cocoapods node and add a new node, maybe, just do it as you say:
Reason: The branch of Cocoapods does not support the latest Xcode version
Solution: Delete the master branch and create a new branch
sudo rm -fr ~/.cocoapods/repos/master
and then again: pod setup
------------------------------split line- -------------------------------------------------- --In the process of
pod setup, the prompt "Setting up CocoaPods master repo" was displayed again. At that time, I felt like I was about to smash the computer. Finally, I didn't give up and checked the size of the cocoapods folder. Result:
. . That's right, read that right, the size keeps increasing. Excitedly waiting.
After about ten or twenty minutes, the pod setup operation was successful.
In this way, the entire cocoapods installation should be successful. I can't wait to try it. Enter "pod search AFNetworking" and something comes out. Then follow the previous tutorial in the terminal, cd to the project general directory
cd /Users/md098/Desktop/PodTest
to create a Podfile (configuration file)
Then go to the previous step, enter vim Podfile in the terminal
, enter i on the keyboard, enter the editing mode, enter
platform:ios, '7.0'
pod 'MBProgressHUD', '~> 0.8'
Then press Esc, and enter the ":" sign to enter the vim command mode, and then enter wq after the colon
. Note: You can enter wq only after entering : on the keyboard. After pressing Enter, I found that there is one more Podfile in the general directory of the PodTest project. The
exciting time has come: make sure the terminal cd to the general directory of the project, and then enter pod install. . . Then you will find out. . .
Prompt this error: [!] The dependency `MBProgressHUD` is not used in any concrete target.
It turns out that the new cocoapods cannot install third parties as before. The current format is to add the target of the project. As follows:
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
pod 'AFNetworking', '~>
Remember to replace MyApp in pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
with the target in your siege (that is, your own project name). This is basically OK, and you can execute pod install / pod update.