1. Ruby 镜像地址变更
http://ruby.taobao.org/ 换成了https://ruby.taobao.org/
taobao提供的镜像地址已经不可用(不再更新)
https://ruby.taobao.org/ 替换为 https://gems.ruby-china.org/
https://gems.ruby-china.org/ 替换为 替换为 https://gems.ruby-china.com
其他教程网上照旧使用即可
2. 最近更新cocoapods出现错误
sudo gem install cocoapods
ERROR: While executing gem ...
(Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
解决办法,改使用下面的命令:
sudo gem install -n /usr/local/bin cocoapods
安装指定版本号的cocoapods
sudo gem install -n /usr/local/bin cocoapods -v 0.39.0
更新gem
sudo gem update -n /usr/local/bin --system
stackoverflow问题详细解答Cannot install cocoa pods after uninstalling, results in error
另外一个比较详细的答案segmentfault
3. 在老项目重构使用 cocoapods 过程中遇到的问题
- 问题描述:
[!] The `Biu [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.
下面还有两个类似的警告
大意是 target 的设置覆盖了 pod 的设置。这个警告会导致再代码编译的时候出现错误
library not found for -lPods
解决方法:
在Build Settings -> Other linker flags 中添加$(inherited)
添加完成之后运行pod update
即可解决警告和相关错误。
- 问题描述:
podfile:
platform :ios, ‘8.0’
target "Biu" do
pod 'AFNetworking',"~> 3.0"
报错:
Undefined symbols for architecture i386:
"OBJC_CLASS$_AFHTTPResponseSerializer"
referenced from: objc-class-ref in HomeViewController.o
...
解决方法:
架构的原因,只要把这两个地方保持一致就可以了
![](http://upload-images.jianshu.io/upload_images/629857-4f029c81640610bf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/629857-1b63e9422f0cc730.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
国外网友给的原因及另外一种相反解决方案,同样能解决问题, 但是看网上说把`Build Active Architecture Only`中的`debug`设置为 Yes 可以加快Debug的编译速度,所以我还是选择我的解决方案吧。
国内网友讨论的主要内容:
> [国内网友讨论地址](http://www.cocoachina.com/bbs/read.php?tid-244345-page-1.html)
这个属性设置为yes,是为了debug的时候编译速度更快,它只编译当前的architecture版本。而设置为no时,会编译所有的版本。
这个是设备对应的architecture:
armv6:iPhone 2G/3G,iPod 1G/2G
armv7:iPhone 3GS/4/4s,iPod 3G/4G,iPad 1G/2G/3G
armv7s:iPhone5, iPod5
编译出的版本是向下兼容的,比如你设置此值为yes,用iphone4编译出来的是armv7版本的,iphone5也可以运行,但是armv6的设备就不能运行。所以,一般debug的时候可以选择设置为yes,release的时候要改为no,以适应不同设备。
国外网友原文如下:
> [国外网友的原文链接](http://samwize.com/2014/05/15/resolving-cocoapods-build-error-due-to-targets-building-for-only-active-architecture/)
> ***Resolving CocoaPods build error due to targets building for only active architecture***
I always have a build error after `pod install`
, because by default, CocoaPods will configure your pods to **build for `active architecture only`** (during debugging).
The solution is to change Pods project setting Build Active Architecture Only to`NO`for debug.
But it is tedious to change every time after you run pod install
(as your change will get reverted back to `YES`).
As [suggested by msmollin](https://github.com/CocoaPods/CocoaPods/issues/1400#issuecomment-39855490) in CocoaPods issues, you can fix by with:
Append to your Podfile
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
#### 4. CocoaPods pod install/pod update更新慢的问题
最近使用CocoaPods来添加第三方类库,无论是执行`pod install`还是`pod update`都卡在了`Analyzing dependencies`不动了,令人甚是DT。
查了好多的资料,原因在于当执行以上两个命令的时候会升级CocoaPods的spec仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:
`pod install --verbose --no-repo-update`
`pod update --verbose --no-repo-update`
#### 5.使用CocoaPods后,发现总是找不到头文件
在TARGETS -> Search Paths -> User Header Search Paths 中 写入 ${SRCROOT} 再将后面参数改为recursive