基本步骤:
>1.添加远程私有索引库(specs)
>2.创建私有库
>3.把私有库的spec 添加到私有索引库
>4.podfile添加
// 第一行添加
source 'https://github.com/china/WTYSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'
//pod "私有库" // 可公有库一样
一.创建私有Specs
1.创建私有Specs
pod repo add [Private Repo Name] [GitHub HTTPS clone URL]
$ pod repo add WTYSpecs https://github.com/china/WTYSpecs.git
比如如何删除私有仓库:pod repo remove [name]。
二.创建私有库:
1.创建私有库
创建私有库命令2.修改podSpec文件
#
# Be sure to run `pod lib lint WTYLogin.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'WTYLogin'
s.version = '0.1.0'
s.summary = ' WTYLogin 是登录模块'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/china/WTYLogin'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { '411041286@qq.com' => 'china@163.com' }
s.source = { :git => 'https://github.com/china/WTYLogin.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '8.0'
s.source_files = 'WTYLogin/Classes/**/*'
# s.resource_bundles = {
# 'WTYLogin' => ['WTYLogin/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
3.创建远程仓库
a. 创建远程仓库4添加远程仓库
$ git remote add origin git@github.com:china/WTYLogin.git
$ git push -u origin master
$ git tag 0.1.0
$ git push origin --tags
5.验证是否通过
TIPS:
pod lib lint是只从本地验证你的pod能否通过验证
pod spec lint是从本地和远程验证你的pod能否通过验证
我一般都是直接使用pod spec lint去验证pod有没有问题
pod spec lint --allow-warnings 忽略警告
deMacBook-Pro:WTYLogin $ pod spec lint
-> WTYLogin (0.1.0)
Analyzed 1 podspec.
WTYLogin.podspec passed validation.
deMacBook-Pro:WTYLogin $
三.添加索引
$ cd 到.pospec 所在目录
$ pod repo push WTYSpecs WTYLogin.podspec
四.调用
// 第一行添加
source 'https://github.com/china/WTYSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'
//pod "私有库" // 和公有库一样
常见问题
1.私有库引用私有库的问题
在私有库引用了私有库的情况下,在验证和推送私有库的情况下都要加上所有的资源地址,不然pod会默认从官方repo查询。
pod spec lint --sources='私有仓库repo地址,https://github.com/CocoaPods/Specs'
如:
pod repo push 本地repo名 podspec名 --sources='私有仓库repo地址,https://github.com/CocoaPods/Specs'
网友评论