cocoaPods的Errors

使用Cocoapods使用的错误

1. ERROR | spec: The specification defined in LZTool.podspec could not be loaded.
MacBook:PodTest Artron_LQQ$ pod lib lint LZTool.podspec

 -> LZTool.podspec
    - ERROR | spec: The specification defined in `LZTool.podspec` could not be loaded.


[!] Invalid `LZTool.podspec` file: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...<-DESC 这是一个测试文档, 这里主要是描述类库...
...                               ^
LZTool.podspec:28: syntax error, unexpected '\n', expecting '='.

 #  from LZTool.podspec:27
 #  -------------------------------------------
 #    #   * Finally, don't worry about the indent, CocoaPods strips it!
 >    s.description  = <<-DESC 这是一个测试文档, 这里主要是描述类库的功能设计初衷介绍
 #                     DESC
 #  -------------------------------------------


[!] LZTool.podspec did not pass validation, due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
    `echo "2.3" > .swift-version`.
You can use the `--no-clean` option to inspect any issue.
MacBook:PodTest Artron_LQQ$

这个错误是使用指令pod lib lint LZTool.podspec 检查文件是否合法时发生的;

可以看出是在设置 s.description 字段时发生的错误, 当时的写法是:

s.description  = <<-DESC LZTool 是一个用于保存一些常用工具类的工具 DESC

以为可以吧他们并到一行, 导致一直报这个错, 后来写成两行, 还是报错, 最后才试出这样写才对:

s.description  = <<-DESC 
                          LZTool 是一个用于保存一些常用工具类的工具
                   DESC
2. [iOS] file patterns: The source_files pattern did not match any file.
MacBook:PodTest Artron_LQQ$ pod lib lint LZTool.podspec

 -> LZTool (0.0.1)
    - WARN  | github_sources: Github repositories should end in `.git`.
    - ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.

[!] LZTool did not pass validation, due to 1 error and 1 warning.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
    `echo "2.3" > .swift-version`.
You can use the `--no-clean` option to inspect any issue.
MacBook:PodTest Artron_LQQ$

这个错误也是使用指令 pod lib lint LZTool.podspec 检查文件是否合法时发生的;

这个是在指定共享的类库时, 文件路径不对, 也就是设置 s.source_files 字段时, 发生了错误, 这里的路径是相对于LZTool.podspec文件的, 如果是与LZTool.podspec同级的文件夹, 直接写文件夹名称即可, 如:

 s.source_files = "LZTool"

如果有多级目录, 一定要逐级添加. 这里也可以这么写:

 s.source_files = "LZTool/*.{h,m}"
3. fatal: Remote branch 0.0.1 not found in upstream origin
MacBook:PodTest Artron_LQQ$ pod spec lint

 -> LZTool (0.0.1)
    - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/LQQZYY/PodTest.git /var/folders/14/95vmx0495_s5292ltvwpsc8h0000gn/T/d20170111-11240-1l3iq9n --template= --single-branch --depth 1 --branch 0.0.1

Cloning into '/var/folders/14/95vmx0495_s5292ltvwpsc8h0000gn/T/d20170111-11240-1l3iq9n'...
warning: Could not find remote branch 0.0.1 to clone.
fatal: Remote branch 0.0.1 not found in upstream origin
) during validation.

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
    `echo "2.3" > .swift-version`.
MacBook:PodTest Artron_LQQ$

这个是使用指令pod spec lint来检查文件是否可用时发生的错误;

这是因为在你托管代码的库里(这里是指github)找不到这个分支, 也就是在编辑 LZTool.podspec时, 里面的字段s.verson, s.source 中的 taggithub创建的release版本号不一致导致, 修改为一样即可!

4. 加载xib问题

如果通过cocoapods下载的类库中含有Xib文件, 使用原来的方式初始化就不起作用了:

[[[NSBundle mainBundle] loadNibNamed:@"xibName" owner:self options:nil] lastObject];
[self.collectionView registerNib:[UINib nibWithNibName:@"xibName" bundle:nil] forCellWithReuseIdentifier:@"ZLCollectionCell"];

改为:

#define kZLPhotoBrowserBundle [NSBundle bundleForClass:[self class]]
[[kZLPhotoBrowserBundle loadNibNamed:@"ZLPhotoActionSheet" owner:self options:nil] lastObject];
[self.collectionView registerNib:[UINib nibWithNibName:@"ZLCollectionCell" bundle:kZLPhotoBrowserBundle] forCellWithReuseIdentifier:@"ZLCollectionCell"];
5. xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information
MacBook:LZSortTool Artron_LQQ$ pod spec lint

 -> LZSortTool (0.0.1)
    - WARN  | [iOS] license: Unable to find a license file
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | [iOS] xcodebuild:  LZSortTool/LZSortToolDemo/LZSortToolDemo/LZSortClass/LZSortTool.m:14:9: fatal error: 'ChineseToPinyin.h' file not found

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 1 error and 1 warning.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
    `echo "2.3" > .swift-version`.
MacBook:LZSortTool Artron_LQQ$

这个是执行pod spec lint指令的时候产生的错误:
这个错误从-NOTE可以看出, 是项目中的这个文件 ChineseToPinyin.h找不到, 回到项目, 编译一下也会报这个错. 是因为我修改了本地文件中的这个文件的路径, 项目中引用的还是原先的路径, 打开左侧文件列表, 可以发现这个文件是红色的, 删除引用, 重新添加, 然后到你的github上面, 重新添加一个release版本, 再重新执行指令即可验证通过.

6: 新建的GitHub仓库没有选择许可证。没法,只能删了重新建。
7: 没有建demo工程并上传到GitHub。只传了Class文件,这个时候验证podspec是通不过的。
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose` for more information.
8: swift版本不对
[!] The validator for Swift projects uses Swift 2.3 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 3.0, run:
    `echo "3.0" > .swift-version`.

使用echo "3.0" > .swift-version命令即可。

9: podspec文件配置不对

需要注意的是s.source_files参数,如果配置为s.source_files = '/*.{h,m}’,会报错:

- ERROR | File Patterns: File patterns must be relative and cannot start with a slash (source_files).

其它可能的报错:

    - ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.

10: 如果依赖了其它CocoaPods第三方库

请使用s.dependency配置,如 s.dependency "SDWebImage", "~> 3.7.1"


Pod::Spec.new do |s|
    s.name         = 'XLPhotoBrowser'
    s.version      = '1.0.2'
    s.summary      = 'a component of photo browser on iOS'
    s.homepage     = 'https://github.com/xiaoL0204/XLPhotoBrowser'
    s.description  = <<-DESC
                    It is a component for ios photo browser,written by Objective-C.
                   DESC
    s.license      = 'MIT'
    s.authors      = {'xiaoL0204' => '[email protected]'}
    s.platform     = :ios, '6.0'
    s.source       = {:git => 'https://github.com/xiaoL0204/XLPhotoBrowser.git', :tag => s.version}
    s.source_files = 'XLPhotoBrowser/**/*.{h,m}','Pods/**/*.{h,m}'
    s.requires_arc = true
end
11: 忘记打tag
Validating podspec
 -> XLPhotoBrowser (1.0.0)
    - ERROR | [iOS] unknown: Encountered an unknown error ([!] /Applications/Xcode.app/Contents/Developer/usr/bin/git clone https://github.com/xiaoL0204/XLPhotoBrowser.git /var/folders/w1/95fypdq96l92t55frcn0yhyh0000gn/T/d20161206-1790-put1kd --template= --single-branch --depth 1 --branch 1.0.0

Cloning into '/var/folders/w1/95fypdq96l92t55frcn0yhyh0000gn/T/d20161206-1790-put1kd'...
warning: Could not find remote branch 1.0.0 to clone.
fatal: Remote branch 1.0.0 not found in upstream origin
) during validation.

[!] The spec did not pass validation, due to 1 error.
12: 找不到自己上传的框架
[!] Unable to find a pod with name, author, summary, or description matching `ZXZTools`
  • 1: 执行pod setup其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下: 终端输入: pod setup
    会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
    如果pod search操作还是搜索失败,如下:
    终端输入:pod search AFNetworking

  • 2: 删除~/Library/Caches/CocoaPods目录下的search_index.json文件
    pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
    终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
    终端输入:pod search afnetworking(不区分大小写)
    输出:Creating search index for spec repo ‘master’.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。

你可能感兴趣的:(cocoaPods的Errors)