CocoaPods报错:The dependency `AFNetworking ` is not used in any concrete target

最近更新了下cocoapods,今天再pod update  就遇到这个错误:

大体意思就是说,库没有用到指定的target。

找了下资料,发现是新版CocoaPods在 Podfile里使用时,必须指定target:

比如:

platform:ios,'7.0'
target ‘TestSwift’ do

pod 'AFNetworking'
pod 'SDWebImage'
pod 'JSONModel'
pod 'MJRefresh'
pod 'SDCycleScrollView','~> 1.64'

end

 

解决方法: 

添加

target ‘TestSwift’ do

end

这两段首尾声明即可。

注意:TestSwift是你的target名

其实,在旧版本,如果我们一个项目里含多个target时,要在不同target里引用第三方库,也是必须指定具体target的,只不过现在升级后,要求即使一个target,也要指定一下,这样就是更正规一点了。

原文地址:https://www.cnblogs.com/yajunLi/p/6163725.html