私有Cocoapods仓库&遇到的问题

Git代码搬迁

  1. 在新Git服务器创建需要迁移的同名空项目(不同名也可以)

  2. Git clone 旧Git代码到本地 (或者本地有Git origin的代码,用Git remote -v 查看)

  3. Git push --mirror 新的空项目地址

  4. 完成后Git clone 新Git上的代码到本地game over

Pod 私有库(子组件)

1. 创建工程以YBBluetoothKit为例
pod lib create YBBluetoothKit
2. 编写 Pod 库

如果使用了 Swift,需要指定 Swift 版本:在 Terminal 中的项目目录下,输入 echo "4.2" > .swift-version,会在项目根目录下生成一个 .swift-version 文件

使用 ( Command + Shift + .)查看影藏文件

3 .Build 项目后,在 Example 工程中测试调用
4. 修改 podspec 文件

必须修改字段

# 当前版本
s.version
# 项目总结
s.summary 
# 项目地址
s.source 
5.本地校验pod lib lint
6. 创建远程库

在Git远端创建项目

7. 关联远程库
git remote add origin "http://101.132.74.65/fengming/YBBluetoothKit"
8.提交代码并为项目打上tag
git add .
git commit -m "project init"
git tag -m "first dev v0.0.1" 0.0.1
git push
git push --tags
9 .联网校验pod spec lint

Pod 私有库(主仓库)

如果已经创建过,就不需要再创建了

1. 在Git远端创建主工作项目 以ManagerSpecRepo为例
2. 将主项目添加(关联)到CocoaPods的目录下
pod repo add ManagerSpecRepo http://101.132.74.65/fengming/ManagerSpecRepo
3.将子组件.podspec添加到ManagerSpecRepo主仓库
pod repo push ManagerSpecRepo YBBluetoothKit.podspec

Pod私有库更新流程

  1. 将修改过的子组件文件的.podspec文件,修改version即可

  2. 打tag,并将tag上传 (git push origin [tagname] / git push origin --tags)

    扫描二维码关注公众号,回复: 5222964 查看本文章
  3. pod lib lint --allow-warnings

  4. pod repo push 主仓库 子组件.podspec --verbose --allow-warnings

  5. 如果有.a都静态库使用--use-libraries

pod repo push ManagerSpecRepo YBBluetoothKit.podspec --verbose --use-libraries --allow-warnings
  1. 如果里面已经依赖了其他私有库 需要指定 sources 地址(以逗号隔开)
pod repo push ManagerSpecRepo YBBluetoothKit.podspec --verbose --use-libraries --allow-warnings --sources="http://101.132.74.65/fengming/ManagerSpecRepo,https://github.com/CocoaPods/Specs.git"

Pod私有库异常整理

1. pod lib lint (检查本地pod)
[!] DemoPodSpecs did not pass validation, due to 2 warnings (but you can use --allow-warnings to ignore them).
 You can use the --no-clean option to inspect any issue.

解决办法:用 pod lib lint --allow-warnings 命令

2. pod spec lint (检查远程pod)
Encountered an unknown error (Simulator is not available.) during validation

解决办法:升级cocoapods sudo gem install -n /usr/local/bin cocoapods --pre

3. pod spec lint (检查远程pod)
[iOS] unknown: Encountered an unknown error (Must be in the root of the repo (/Users/*.cocoapods/repos/master), instead in ....

解决办法:可能是因为更新完Xcode以后Xcode路径更改了,Xcodebuild找不到路径。 执行命令 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

4. pod repo push DemoPodSpecs DemoPodSpecs.podspec

The DemoPodSpecs.podspec specification does not validate.

解决办法: pod repo push DemoPodSpecs DemoPodSpecs.podspec --verbose --use-libraries --allow-warnings

5. pod repo push DemoPodSpecs DemoPodSpecs.podspec --verbose --use-libraries --allow-warnings
/usr/bin/git -C /Users/.cocoapods/repos/DemoPodSpecs -C
 /Users/.cocoapods/repos/DemoPodSpecs push origin master
 fatal: repository '' not found

解决办法:到 /Users/.cocoapods/目录下查看私有pod库是否存在

6. pod lib lint
[!] 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`.

解决办法:运行 echo 4.2 > .swift-version

7. Pod install

7.1

[!] CocoaPods could not find compatible versions for pod "YBCoreKit":
  In snapshot (Podfile.lock):
    YBCoreKit (= 1.2.1)

  In Podfile:
    YBSDKPayKit (from ../) was resolved to 1.8.1, which depends on
      YBCoreKit

It seems like you've changed the constraints of dependency YBCoreKit inside your development pod YBSDKPayKit.
You should run pod update YBCoreKit to apply changes you've made.

解决办法:

  1. 注释掉source,和所以pod 库,以及pod 'demo', :path => '../',然后 pod install
  2. 重新打开注释掉的内容,然后 pod install

7.2 Unable to find a specification for ""
解决办法:
别着急pod update 一下就好了

猜你喜欢

转载自blog.csdn.net/weixin_34279061/article/details/87511564