制作私有的CocoaPods仓库


个人记录,详请参考官网

1.创建一个私有Spec仓库

注意不要是一个空仓库,起码有一个README.md文件,否则后边会报错

2.添加私有的spec库到已安装的cocoapods中
$ pod repo add REPO_NAME SOURCE_URL

REPO_NAME为自定义仓库名称
SOURCE_URL为仓库地址

检查安装是否成功并准备就绪

$ cd ~/.cocoapods/repos/REPO_NAME
$ pod repo lint .

注意REPO_NAME为自己定义的仓库名字

3.将Podspec文件添加到私有spec仓库

模板项目创建参考https://www.jianshu.com/p/1dfdcc880eb3

podspec问价的.source私有库注意使用git开头地址,否则别的小伙伴install需要密码
注意验证podspec文件时,有第三方库需要指定源,多个源指定多个
否则会创建~/.cocoapods/repos/路径下的trunk仓库
造成Found multiple specifications for "xxxxxxxx"错误

pod spec lint xxxx.podspec --allow-warnings --sources='https://github.com/CocoaPods/Specs.git'

或者在xxxx.podspec文件目录下直接执行
pod spec lint --allow-warnings --sources='https://github.com/CocoaPods/Specs.git'

最后push到自己的私有spec仓库

$ pod repo push REPO_NAME SPEC_NAME.podspec

或者在该文件目录下直接
pod repo push REPO_NAME --allow-warnings

可以不验证,直接使用
pod repo push REPO_NAME --allow-warnings --sources='https://github.com/CocoaPods/Specs.git


问题:
Found multiple specifications for "xxxxxxxx"
解决方法参考https://www.jianshu.com/p/c3d66998e0c7

Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
specs索引仓库没有README.md文件,gitlab可以直接在网站添加

注意:当Podfile引自己的私有库时,需要同时添加自己的私有source
source 'xxxxx.git'

问题:
Cloning into '/var/folders/w2/7z13y7z50ldc1hc1zmg4xg000000gn/T/d20200722-5081-1c3q5k6'...
warning: Could not find remote branch 0.1.0 to clone.
fatal: Remote branch 0.1.0 not found in upstream origin
原因是未打版本tag并推送到远端
如果一直提示,可以尝试将podspec文件的.source地址改成http操作,再换回git开头

问题:
You have either:

  • out-of-date source repos which you can update with pod repo update or with pod install --repo-update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.
    使用pod install --repo-update

问题:
[!] Failed to connect to GitHub to update the aliyun/aliyun-specs specs repo - Please check if you are offline, or that GitHub is down

1. brew upgrade openssl
2. brew upgrade ruby
3. pod repo update master

参考:
CocoaPods搭建私有库

你可能感兴趣的:(制作私有的CocoaPods仓库)