我是对之前的一个老项目添加cocoapods来替换手动添加的三方库,一切都很顺利,编译也没问题,结果一运行,
我当时就懵逼了,急的我,我以为pod导入三方库有问题,我就删除了重新导入,还是不行,我以为是cocoapods出了问题,ok,捣鼓一下,结果把cocoapods搞出了事,花了两天时间,最后找到了原因,都是“Other Linker Flags”
下面有个概念,可以看看:
http://blog.csdn.net/cjh965063777/article/details/51880966
找到原因就好办了,顺便还可以解决pod里面出现的警告:
[!] The `Paopao [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Paopao [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Paopao [Release]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Paopao [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
简单粗暴法:点击项目文件 project.xcodeproj,右键显示包内容
,用文本编辑器打开project.pbxproj
,删除OTHER_LDFLAGS
的地方,保存,pod repo update --verbose,警告没了,问题也解决了,整个人都好了。。。。
------------------------------------下面是自己挖的坑,cocoapods走一遍----------------------------------
首先cocoapods无缘无故出现问题不要动不动就卸载,事情越搞越大,无非就是更新一下
sudo gem install -n /usr/local/bin cocoapods
1,简单说下cocoapods的安装吧,淘宝源也不能用了,所以替换一下:
gem sources --remove https://rubygems.org/
gem sources -a https://gems.ruby-china.org/
查看下替换成功没,打印出来就替换成功了:
gem sources -l
2.更新升级gem,如果它的版本过低也可能导致安装失败,在终端输入以下命令:
sudo gem update --system
3.安装CocoaPods:
OS X 10.11以前,在终端输入以下命令:
sudo gem install cocoapods
OS X 10.11以后,在终端输入以下命令:
sudo gem install -n /usr/local/bin cocoapods
4.初始化:
在终端输入以下命令:
pod setup
这一步是问题最多的一步,下面慢慢说
查看下版本,是否安装成功,我目前的版本是:1.2.0.beta.3
pod --version
5.问题梳理:
(1)在终端输入以下命令:
pod repo list
结果为0 repos时说明安装不成功,自己可以查看下自己的安装步骤,看看是哪一步出现了问题。
(2)出现以下错误:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
在网上寻找的解决方法:
在终端中输入:sudo nvram boot-args="rootless=0"; sudo reboot
然后你的电脑会重启
之后再输入sudo gem install cocoapods -V
就可以了。
(3)pod setup时出现以下错误:
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
自己按照提示在终端输入以下命令:
pod repo add master https://github.com/CocoaPods/Specs.git
还是报错!
在网上查到的解决办法:在终端输入以下命令:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developers
后面的地址你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面。
(4)试过以上所有解决办法,还是没有安装成功:
重新安装(其实我就是这样安装成功的):
首先,删除.cocoapods目录,在终端输入以下命令:
sudo rm -rf ~/.cocoapods/
然后,重新下载安装,在终端输入以下命令:
pod setup
如果这都还不行,就只有放终极绝招了,亲测有效sudo rm -rf ~/.cocoapods/
$ sudo gem install -n /usr/local/bin cocoapods
$ Git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
最后再pod setup 一下,应该是没问题了
下面有两篇很不错的文章,关于cocoapods的
http://www.jianshu.com/p/b5315bf42975
http://www.jianshu.com/p/ffc0a67d6d75