组件化问题汇总

1.cocoapads添加依赖私有库,提交报错的问题解决

自己的一个私有库添加了另一个私有库,进行验证时报如下错误:找不到相对应的类库

localhost:XTBloginPage liuyihua$ pod lib lint
XTBloginPage (0.1.6)
 ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for `XTBBaseLib/Network` depended upon by `XTBloginPage`) during validation.
 [!] XTBloginPage 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.

localhost:XTBloginPage liuyihua$ pod env

主要的原因是cocoapods不知道你的私有库存放在那一个远程库中,需要自己明示仓库来源 :本地验证和提交远程都一样;

$pod lib lint --sources='https://git.coding.net/xxxxxx/LYHXTBSepc.git,https://github.com/CocoaPods/Specs.git' --use-libraries --allow-warnings

localhost:XTBloginPage liuyihua$ pod lib lint --sources='https://git.coding.net/xxxxxx/LYHXTBSepc.git,https://github.com/CocoaPods/Specs.git' --use-libraries --allow-warnings

 -> XTBloginPage (0.1.6)
XTBloginPage passed validation.
localhost:XTBloginPage liuyihua$ 

提交远程仓库

localhost:XTBBaseLib liuyihua$ pod repo push LYHXTBSepc Lib.podspec  --sources='https://git.coding.net/xxxxxx/LYHXTBSepc.git,https://github.com/CocoaPods/Specs.git' --use-libraries --allow-warnings

验证通过!

2.cocoapods 上传私有库或者远程库遇见的问题汇总

一、本地验证报错 $ pod lib lint

       localhost:XTBMain liuyihua$ pod lib lint
       -> XTBMain (0.1.3)
          - ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for `XTBBaseLib/Category` depended upon by `XTBMain`) during validation.

      [!] XTBMain 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.
      localhost:XTBMain liuyihua$ 

根据提示信息,我们了解到主要是因为
私有库的 'XTBBaseLib/Category '找不到
假如你已经创建好私有库A,并想在私有库B中使用私有库A,在库B的.podspec文件中你需要制定依赖:

  s.dependency 'pod projectName(A)', '~> version'

校验sepc可用性时,执行以下命令:

  pod sepc lint 文件名.podspec

发生错误:

   - ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for `XTBBaseLib/Category` depended upon by `XTBMain`) during validation.

原因

校验podspec文件时会到远程podspec库查找相关依赖,默认只会到官方specs库校验,此时需要指定远程specs库去校验。

解放方案:

  localhost:XTBMain liuyihua$ pod spec lint 文件名.podspec --sources='http://[privateLibName]/cocoaspecs.git,https://github.com/CocoaPods/Specs.git'

  -> XTBMain (0.1.3)

  XTBMain passed validation.
  localhost:XTBMain liuyihua$

参考地址:http://m.blog.csdn.net/article/details?id=50515434

3.CocoaPods 错误 target overrides the 'OTHER_LDFLAGS'...

        [!] The `Paopao [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

     [!] The `Paopao [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

 [!] The `Paopao [Release]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

       [!] The `Paopao [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.

这种警告是不能忽视的,它带来的直接后果就是无法通过编译。直接报错:

 ld: symbol(s) not found for architecture x86_64 clang:
 error: linker command  ........

而产生此警告的原因是项目 Target 中的一些设置,CocoaPods 也做了默认的设置,如果两个设置结果不一致,就会造成问题。

我想要使用 CocoaPods 中的设置,分别在我的项目中定义PODS_ROOTOther Linker Flags的地方,把他们的值用$(inherited)替换掉,进入终端,执行

   pod update --verbose --no-repo-update
组件化问题汇总_第1张图片
image.png
组件化问题汇总_第2张图片
image.png

写了一个简单的类似于支付宝首页的菜单选择的类库(这是地址),已经完成了提交到了cocopads远程仓库上,

组件化问题汇总_第3张图片
image

但是就是在进行 pod search HZChooseButton 就搜索不到报错信息,如下:

image

解决过程如下:

一开始我想是不是因为版本的问题,

执行pod setup

在终端输入pod setup,会出现Setting up CocoaPods master repo,等几分钟,会输入Setup

completed,说明pod setup执行成功。

结果pod search还是失败

组件化问题汇总_第4张图片
image

但是我输入pod search AFN,却有相应的结果。

随后进行的百度了一下,发现是 search_index.json 文件的问题,需要 删除~/Library/Caches/CocoaPods目录下的search_index.json文件

终端输入rm ~/Library/Caches/CocoaPods/search_index.json

删除成功后再执行 $ pod search HZChooseButton 成功了!

image
组件化问题汇总_第5张图片
image

你可能感兴趣的:(组件化问题汇总)