Cannot install Alamofire 4.0 in Xcode 8.0 Using CocoaPods

a 夏天 提交于 2019-12-19 21:25:52

问题


I need to upgrade one project to Swift 3.0, that has some libraries by Cocodpods. So, I've removed all links related with Cocoapods and recreate pod file using pod init and upgrade some version of library such as AlamorFire.
But pod install said

[!] Unable to satisfy the following requirements:

- `Alamofire (~> 4.0)` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `Alamofire (~> 4.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

I've updated deployment Target to 9.0 and using cocoapod 1.1.0
For test, I've created new project and added only Alamofire, but the result is same. If you have some experience, please help me.


回答1:


Since you have an outdated pod repo, pod install getting failed. First of all you have to update your pod master repo before running pod install. Follow the steps given to update your pod repo and resolve the pod error.

  • Go to Cocoa Pods repo folder (~/.cocoapods/repos) and delete master folder
  • Run pod update on terminal. This will take several minutes to update pod repo.
  • When update get finished, run pod install (if required).

Hope this would be useful for those who are getting similar error :)




回答2:


try sudo gem install cocoapods --pre

the pod file should look like

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target 'YourAPP' do
    pod 'Alamofire', '~> 4.0'
    pod 'SwiftyJSON', :git => 'https://github.com/acegreen/SwiftyJSON.git', :branch => 'swift3'
    pod 'NetReachability'
end


来源:https://stackoverflow.com/questions/39694162/cannot-install-alamofire-4-0-in-xcode-8-0-using-cocoapods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!