在从gitHup上拉代码后,等你刚pod install 安装了程序依赖的pod 库之后,会发现怎么运行xcode 都 编译报上面这句错ld: library not found for -lPods-你的工程名 -AFNetworking ,就是link的时候找不到第三方库。
解决方案如下:
我研究了一星期 ,试了很多次,最后发现是因为我新电脑默认安装的pod 版本是 0.39.0 而 我们公司git仓库上是0.35.0,就是因为我用的pod 版本过高,所以在pod install 后就会编译报错。
查看pod 版本在终端下输入 pod --version
(国内的pod安装大家也知道一般都比较慢,另外,如果你pod install 比较慢的话,那就改你的dns 加上114.114.114.114.)
废话不多说,直接上我这个问题的最终解决方案
1.打开终端,查看安装gem 程序列表。
输入gem list
会发现输出如下:
cocoapods (0.39.0)
cocoapods-core (0.39.0)
cocoapods-downloader (0.9.3, 0.8.1)
cocoapods-plugins (0.4.2, 0.3.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2)
cocoapods-trunk (0.6.4, 0.4.1)
卸载命令:sudo gem uninstall cocoapods
或者sudo gem uninstall cocoapods -v 0.35.0
(后面加-v 是指定版本,不加的话,就可以选择卸载所有的)
会看到例如下面输出
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods
Password:
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn] y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-0.39.0
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-core
Successfully uninstalled cocoapods-core-0.39.0
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-downloader
Select gem to uninstall:
1. cocoapods-downloader-0.8.1
2. cocoapods-downloader-0.9.3
3. All versions
> 3
Successfully uninstalled cocoapods-downloader-0.8.1
Successfully uninstalled cocoapods-downloader-0.9.3
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-plugins
Select gem to uninstall:
1. cocoapods-plugins-0.3.2
2. cocoapods-plugins-0.4.2
3. All versions
> 3
Successfully uninstalled cocoapods-plugins-0.3.2
Successfully uninstalled cocoapods-plugins-0.4.2
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-search
Successfully uninstalled cocoapods-search-0.1.0
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-stats
Successfully uninstalled cocoapods-stats-0.6.2
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-trunk
Select gem to uninstall:
1. cocoapods-trunk-0.4.1
2. cocoapods-trunk-0.6.4
3. All versions
> 3
Successfully uninstalled cocoapods-trunk-0.4.1
Successfully uninstalled cocoapods-trunk-0.6.4
wangfeideMacBook-Pro:iOS-Application wangfei$ sudo gem uninstall cocoapods-try
Select gem to uninstall:
1. cocoapods-try-0.4.5
2. cocoapods-try-0.5.1
> 3
Successfully uninstalled cocoapods-try-0.4.5
Successfully uninstalled cocoapods-try-0.5.1
在终端输出命令:sudo gem install cocoapods -v 0.35.0
4.安装完毕,检查版本
在终端输入:pod --version 查看
输出如下:
wangfeideMacBook-Pro:iOS-Application wangfei$ pod --version
0.35.0
5.好了,然后,再回到你项目目录,最好删掉原来项目,重新拉取下代码,再重新pod install .
问题就解决了。