前言:出現(xiàn)這個(gè)問題,一般是因?yàn)閏ocopod出現(xiàn)問題壮池,百度了百度偏瓤,發(fā)現(xiàn)解決方法,但是解決完發(fā)現(xiàn)又坑爹的不行了椰憋,再記錄下解決步驟厅克。
打開終端
1.cd 到你當(dāng)前項(xiàng)目的文件夾
2.pod install
pod install后你會(huì)發(fā)現(xiàn)出現(xiàn)了一個(gè)新的問題,就是
[!] Unable to add a source with url https://github.com/CocoaPods/Specs.git
named master
.
You can try adding it manually in ~/.cocoapods/repos
or via pod repo add
.
如果有出現(xiàn)橙依,就執(zhí)行下面的步驟(后面解決辦法都基于這個(gè)問題的后續(xù))
3.pod repo add master https://github.com/CocoaPods/Specs.git
4.pod setup
如果出現(xiàn)
[!] The master
repo is not a git repo.
進(jìn)入/users/你的用戶名/.cocoapods/repos证舟,刪除master文件夾
5.再執(zhí)行一次pod setup
6.pod install
本來以為這時(shí)候已經(jīng)可以了硕旗,可是又發(fā)現(xiàn)了一個(gè)新的問題,所有庫的依賴引用都不行了女责?
7.sudo gem install cocoapods --pre
好吧漆枚,我更新了一下cocopod的庫,
還原到上一個(gè)版本抵知,這里更新最新版本也可以
然后輸入密碼墙基,等待install上一個(gè)版本,執(zhí)行完后發(fā)現(xiàn)還是不行刷喜,什么鬼残制?查了下,也可能是podfile出現(xiàn)了問題掖疮,然后我去改了podfile的格式痘拆。
8.在創(chuàng)建Podfile的時(shí)候,用這種格式使用(官方推薦這么使用)
platform :ios, '8.0'
#use_frameworks!個(gè)別需要用到它氮墨,比如reactiveCocoa
target 'MyApp(自己項(xiàng)目的名稱)' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
或者
platform :ios, '8.0'
#use_frameworks!個(gè)別需要用到它纺蛆,比如reactiveCocoa
def pods
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
target 'MyApp' do
pods
end
9.最后再pod install就成功了
總結(jié):想了一下,可能是xcode8的podfile的文件跟xcode7是不一樣的规揪,所以需要更新這部分才可以解決桥氏。
感謝以下文章:
1.CocoaPods報(bào)錯(cuò):The dependency AFNetworking
is not used in any concrete target
2.iOS - 解決Unable to add a source with url https://github.com/CocoaPods/Specs.git
named