cocoapods错误总结

3,923 阅读1分钟

1 报错:Pods written in Swift can only be integrated as frameworks; add use_frameworks! to your Podfile or target to opt into using it. The Swift Pods being used are: ReactiveCocoa, ReactiveSwift, and Result

解决:在想应的pod 'ReactiveCocoa'下添加use_frameworks!

ps:注意use_frameworks!后面的!号

2 集成cocoapods的时候报错:'xxx' file not found with include; use "quotes" instead

解决:引用路径的问题,更改引用路径。例如:#import <JSONModel.h>,改成#import <JSONModel/JSONModel.h> 就可以了

3 集成cocoapods的时候报错:include of non-modular header inside framework module 'XXX': 'XXX' [-Werror,-Wnon-modular-include-in-framework-module]

解决:引用路径的问题,更改引用路径。例如:#import "JSONModel.h",改成#import <JSONModel/JSONModel.h> 就可以了

4 集成cocoapods的时候报错:include of non-modular header inside framework module 'XXX': 'XXX' [-Werror,-Wnon-modular-include-in-framework-module]

解决:如果第3条解决不了,在pod spec lint后添加--use-libraries。同时在pod trunk push 或者pod repo push 【私有库】的后添加--use-libraries

--use-libraries表示使用静态库或者是framework,这里主要是解决当我们依赖一些framework库后校验提示找不到库的时候用到。

5 集成cocoapods的时候报错:Encountered an unknown error (Unable to find a specification for xxx depended upon by xxx

解决:在集成cocoapods的时候添加私有或者公有或者两者都有的sources。如公有的sources。pod repo push xiaofengCocoapodsRepo --sources=https://github.com/CocoaPods/Specs.git

6 删除pod库的时候,报错unable to open file (in target "xxx" in project "Pods")

解决:是你删除了这个库,但是代码中有引用这个库的地方,清除这些引用就好了

7 制作pod库验证的时候报错CompileC /路径/xxx.o /路径/xxx.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler

解决:这种错误就是出在xxx.m文件本身,常见的错误有

  1. xxx.m引用了三方库,但是在spec文件里没有依赖这个库