1.
结果这里我直接报
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200325-10298-1c0azuc.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
那根据他的提示我们可以知道:
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
这里提示无法获取到ruby的头文件。
2.安装cocopods遇到的Error :While executing gem ... (Gem::FilePermissionError) You don't have write p...
解决方法:当终端执行 sudo gem install cocoapods 命令出现Error,替换为 sudo gem install -n /usr/local/bin cocoapods
这些错误基本cocoapods升级版本到1.0.0之后的版本所造成的
错误1、
当写在Podfile文件中的第三方框架,不能使用,找不到时
查看Pods文件夹,是否下载了所需要的第三方框架,没有的话就 pod update
错误2、
Could not automatically select an Xcode project. Specify one in your Podfile like so:xcodeproj 'path/to/Project.xcodeproj'
在Podfile文件里指定下工程目录就行了
xcodeproj 'Demo/Demo.xcodeproj'
但是如果cocoapods版本为(1.0.0或更高)的话,可能会有以下警告
[!] xcodeproj was renamed to `project`. Please use that from now on.
这时只需要把xcodeproj改为 project就行了
project 'Demo/Demo.project'
错误3、
The dependency `AFNetworking (~> 3.0)` is not used in any concrete target.
在Podfile中添加
target‘项目名'do (如 target 'Demo' do )
错误4、
[!] Invalid `Podfile` file: syntax error, unexpected end-of-input, expecting keyword_end.
在Podfile的末尾添加 end
错误5、
Unable to find the Xcode project `/Volumes/BIAO/iOS/code/MBWB.xcodeproj` for the target `Pods`.
在Podfile中 将 project 'Demo/Demo.project’ 改成 project 'Demo.project'
错误6、
build diff: /../Podfile.lock: No such file or directory
在工程设置中的Build Phases下删除Check Pods Manifest.lock及Copy Pods Resources
2018
错误7、 RuntimeError - [Xcodeproj] Unknown object version.
[Xcodeproj] Unknown object version. /Applications/CocoaPods.app/Contents/Res...
原因: Xcode 版本和 CocoaPods 的版本不匹配,需要更新 CocoaPods
解决方法:终端输入命令 $ gem install cocoapods --pre
还有一个更新慢的问题:无论是执行pod install还是pod update都卡在了Analyzing dependencies不动
原因在于当执行以上两个命令的时候会升级CocoaPods的spec仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
补充:cocoapods也有了自己的客户端,可以直接使用 https://cocoapods.org/app
8.[!] 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`.
9. Setting up CocoaPods master repo 卡着不动
一、git clone方法安装cocoapods
镜像实在太多坑了,琢磨了一下另一种安装cocoapods的方法。
在终端中,进入该目录。
cd ~/.cocoapods/repos
若没有以上目录,执行下面指令,出现.cocoapods的目录后可以ctrl+c终止安装。sudo gem install cocoapods是常规的安装方法,不过现在只是用来建立一下.cocoapods目录。手动建立.cocoapods目录应该也是可以的,不过没试过。如果能进入~/.cocoapods/repos的目录就忽略下面一条指令。
sudo gem install cocoapods
克隆一个Specs库,在终端必须进入到~/.cocoapods/repos的目录才执行以下命令。
git clone https://github.com/CocoaPods/Specs
完成后,执行open .打开当前目录repos
open .
然后把Specs目录改名为master即可。~/.cocoapods/repos的目录层级如下:
如果gitclone还慢的话,直接上https://github.com/CocoaPods/Specs点击下载。根据上面的目录结构图,放对了就好。