使用CocoaPods过程中遇到的问题及解决方法

1、Could not automatically select an Xcode workspace

  • 错误提示:
Could not automatically select an Xcode workspace. Specify one in your Podfile like so:

    workspace 'path/to/Workspace.xcworkspace'
    xcodeproj 'path/to/Project.xcodeproj'
  • 解决方法:
    1、在终端通过 cd 命令切换路径到 Podfile 文件所在目录
    2、编辑 Podfile:XXX为工程名,下面是自己引入的类库
target 'XXX' do
pod 'AFNetworking', '~> 3.0'
end

3、在终端输入命令 pod install �或者 pod update

  • 注意:Podfile文件要放在 XXX.xcodeprojXXX.xcworkspace 同一目录下。

2、The `master` repo requires CocoaPods 0.18.1

  • 错误提示:
The `master` repo requires CocoaPods 0.18.1 - 
Update Cocoapods, or checkout the appropriate tag in the repo.

没有更新到最新的Cocoapods版本

  • 解决方法:
    更新 CocoaPods :
    $ [sudo] gem update cocoapods
    如果你想尝试一个预发布版本的CocoaPods可以运行:
    $ [sudo] gem update cocoapods --pre

  • 参考链接:Updating CocoaPods

3、Errno::EPERM - Operation not permitted

  • 错误提示:
Errno::EPERM - Operation not permitted - /Users/../Pods/Pods.xcodeproj/xcuserdata/root.xcuserdatad
  • 解决方法:
    在终端运行:
sudo gem install -n /usr/local/bin cocoapods

4、The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.

  • 错误提示:
The dependency `AFNetworking (~> 3.1.0)` is not used in any concrete target.
  • 解决方法:

添加 target名,如下:

target 'XXX'  do
pod 'AFNetworking'

end

其中XXX要换成当前 target名,最后不要忘记增加一个 end 结尾。

然后重新进行

pod install

5、安装或更新第三方库时出现警告:Your Podfile has had smart quotes sanitised

Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

大意就是你得 Podfile 文件里面有部分引号不合法,不要使用文本编辑。

注意:Podfile 文件里面引号应该是 ',而不是 。注意区分。

  • 1、不要使用文本编辑去编辑Podfile文件,使用Xcode编辑,或者使用终端敲命令去编辑。

  • 2、Podfile 的内容语法格式有问题。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容