iOS development - the pit of AFNetWorking 3.0 on CocoaPods

http://www.jianshu.com/p/f42d1940da54

 

AFNetWorking released the beta version 3.0 in October, and released five official versions from 3.0.0 to 3.0.4 on the 11th to the 19th of December, which is not slow. Importing AFNetWorking into the test project with the mentality of learning, the command in the Podfile is as follows:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' pod 'AFNetworking', '~> 3.0'
the expected result is to drink saliva, and then start to code the result, it backfires, an error is reported, and the result is as follows:

 

[!] Unable to satisfy the following requirements:  

AFNetworking (~> 3.0)required byPodfile`


If you have encountered this problem or you know the solution to this problem, then you can go and drink water and ignore me. The first time I encountered a problem with a pod installation project, I was at a loss. I stepped on the pit and slowly got up. . The following content is a thought process to solve the problem, and I will share with you.

downgrade

If the version of AFNetWorkinga is too high, then downgrade the version and set it to 2.6.0. After a while, the installation will be successful. At this time, it is a bit at a loss. Why is 2.6.0 OK, but not 3.0? Is 3.0 special?

AFNetWorking3.0 installation requirements

CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+.
Xcode 7+ is required.

After pod --versionchecking, the version is indeed 0.39.0, which is also very incomprehensible. I searched the Internet to no avail. At this time, I was wondering if AFNetWorking was updated too quickly and was not released on CocoaPods. It turned out that I was wrong, but it is true I thought of an order~

version view

Through AFNetWorking on CocoaPods , the latest version screenshots are as follows:


version screenshot.png


I was surprised by the search I just thought of pod search AFNetWorking, and found that the highest version is 2.6.0. To put it simply, the data of the local third library is out of sync with the remote data, which causes the local version library of CocoaPods to be lower than the remote ~ here In fact, there is a problem, first to solve the problem of version out-of-sync~

Upgrading the CocoaPods native library

The upgrade is basically a re-installation of CocoaPods. If the default is Taobao's ruby ​​source, you can go directly to 1, 5, and 6.
$ sudo gem update --system // 先更新gem $ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/ $ gem sources -l //查看ruby地址 $ sudo gem install cocoapods // 安装cocoapods $ pod setup
One problem to pay attention to here is the last step pod setup, which will be slightly slower:

Creates a directory at ~/.cocoapods/repos
which will hold your spec-repos. This is where it will create a clone of the public master
spec-repo from:

https://github.com/CocoaPods/Specs

If the clone already exists, it will ensure that it is up-to-date.

After the update is complete:


version view.png

Scope of Search

Through pod search, we can check the version of the third-party library, the local third-party library is not synchronized with the Internet, why the search results are only local, instead of finding online results, then verify whether the search only finds locally in .cocoapods Screenshot of the path below:


local warehouse.png


If we delete the three versions marked in red, will we not be able to find these three versions?


The result after deletion.png

interest discussion

The three test versions of AFNetWorking deleted in the above picture cannot be found out, and of course cannot be updated, that is, the version you added should exist locally, otherwise it cannot be updated.
We often download the code because of slowness in our development. Not updating the local dependency library is actually a bad habit. It may cause the third-party version of the local repository to be lower than the version of the CocoaPods server:
pod install xx --verbose --no-repo-update
what happens if we delete AFNetWorking?
Everything needs to start all over again, you You need to uninstall the existing CocoaPods first, and then repeat the steps of upgrading the version library. I deleted it and tried it, and the feeling of starting over is not so wonderful~

After discussing the problem, it’s time to go to bed. You can rest early if you read the article~



Text/FlyElephant (author of Jianshu)
original link: http://www.jianshu.com/p/f42d1940da54
The copyright belongs to the author, please contact the author for authorization, and mark "author of Jianshu".

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326803828&siteId=291194637