安装 CocoaPods
如果您在macOS 10.9.0-10.9.2上进行安装,则当RubyGems尝试安装json gem时可能会遇到问题。 要解决这个问题请按照这些说
从macOS 10.8升级到10.9后,即使重新安装了Gem,安装的CocoaPods gem也无法工作。 要解决这个问题,您可能需要先卸载该gem,然后重新安装。
$ gem uninstall cocoapods
$ gem install cocoapods
The gem might not be able to compile, to solve this you might need to symlink GCC.
If you used an pre release version of Xcode you might need to update the command line tools.
CocoaPods is not compatible with MacRuby.
If you get the error "ERROR: While executing gem ... (Errno::EPERM); Operation not permitted - /usr/bin/fuzzy_match" then try: $ sudo gem install -n /usr/local/bin cocoapods
使用 CocoaPods project
如果某些东西看起来不起作用,首先要确保您没有完全覆盖项目构建设置中从Pods.xcconfig文件中设置的任何选项。 要为项目的构建设置中的选项添加值,请在 $(inherited) 前加上值列表。
-
如果Xcode无法找到依赖关系的头文件:
- 检查pod头文件是否在 Pods / Headers 中正确链接,并且不覆盖 HEADER_SEARCH_PATHS(请参阅#1)。
- 确保您的项目正在使用 Pods.xcconfig 。 要选中此项目,请选择您的项目文件,然后再次在第二个窗格中选择它并在第三个窗格中打开“信息”部分。 在配置下,您应该为需要安装的 Pod 的每个配置选择Pods.xcconfig。
- 如果 Xcode 仍然无法找到它们,作为最后的手段,您可以预先输入您的导入内容,例如 #import“Pods / SSZipArchive.h”。
-
如果您遇到无法识别的C编译器命令行选项的错误,例如 cc1obj: error: unrecognised command line option "-Wno-sign-conversion":
- 确保您的项目构建设置被配置为使用“Apple LLVM编译器”(clang)
- 您是否在 ~/.profile 中设置了CC,CPP或CXX环境变量? 这可能会干扰Xcode构建过程。 从〜/
.profile中移除环境变量。
-
如果Xcode在链接时出现 - Library not found for -lPods, it doesn't detect the implicit dependencies:
- 去 Product > Edit Scheme
- Click on Build
- 添加Pods静态库,并确保它位于列表的顶部
- Clean and build again
- 如果这不起作用,请确认您试图包含的规范的源已从GitHub中提取。 通过查找 <Project Dir>/Pods/<Name of spec you are trying to include> 来执行此操作。 如果它是空的(不应该是),请验证~/.cocoapods/master/<spec>/<spec>.podspec 在其中包含正确的 github 网址。
- 如果仍然不起作用,请检查您的Xcode构建位置设置。 转到 Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".
-
如果您尝试将应用提交至App Store,并发现 "Product" > "Archive" 在 "Organizer" 中不产生任何内容:
- 在Xcode的 "Build Settings" 中,找到 "Skip Install" 。 在您的应用程序目标上将 “Release” 的值设置为“NO”。 再次 Build ,它应该工作。
我可以用静态库解决 ‘Duplicate Symbol’ 错误吗?
这通常发生在使用包含应用程序通用依赖关系的闭源第三方库时。 一个暴力的解决方法是从静态库中删除依赖项,如此处所述.
但是,通常情况下,供应商应该为其包含的任何依赖项添加前缀,因此您不需要处理它。 发生这种情况时,请与供应商联系并要求他们将其修复,并将上述方法作为临时解决方法。
运行pod命令时出现一些错误
从CocoaPods 0.32.0开始,删除了以root身份运行pod命令的功能,以防止CocoaPods在以root用户身份混合和匹配运行时进入不一致状态。
如果您在一个阶段以root身份运行CocoaPods,则在执行某些操作时可能会开始获取权限被拒绝的错误。 当您遇到许可错误时,您可能需要删除以超级用户身份运行的旧文件,例如缓存数据。 您可以使用以下命令执行此操作。
$ sudo rm -fr ~/Library/Caches/CocoaPods/
$ sudo rm -fr ~/.cocoapods/repos/master/
除了这些全局文件之外,在任何有Podfile的地方也可能有一个Pods目录。 如果您仍然收到权限错误,则应该删除此目录,然后运行pod install。
$ sudo rm -fr Pods/
我想要的修正是在master /分支中,但我现在被阻止
There is a guide for using a version of CocoaPods to try new features that are in discussion or in implementation stage.
<I didn't find the solution to my problem!
We have multiple avenues for support, here they are in the order we prefer.
Stack Overflow, get yourself some internet points. This keeps the pressure off the CocoaPods dev team and gives us time to work on the project and not support. One of the advantages of using Stack Overflow is that the answer is then easily accessible for others.
CocoaPods Mailing List, the mailing list is mainly used for announcements of related projects and for support.
If your question is regarding a library (to be) distributed through CocoaPods, refer to the spec repo.
<I think this is a bug with CocoaPods
In this case we want to get it on a GitHub issues tracker, we use this to keep track of the development work we have to do.
Search tickets before you file a new one. Add to existing tickets if you have new information about the issue.
Only file tickets about the CocoaPods tool itself. This includes CocoaPods, CocoaPods/Core, and Xcodeproj.
Keep tickets short but sweet. Make sure you include all the context needed to solve the issue. Don't overdo it. Great tickets allow us to focus on solving problems instead of discussing them.