其实私有CocoaPods
仓库搭建算不上什么奇技淫巧,而是iOS开发者程序员的基本技能,其中仅包含了两项所需技能:Git
与CocoaPods
。
首先,我们新建一个Git
仓库,并以README.md
初始化master
,不管是公网还是内网,只要开发时能访问到,这里以gitee为例,创建一个名为UtopiaPods
的仓库:
将UtopiaPods
添加到CocoaPods
的repo
中:
pod repo add UtopiaPods '仓库git地址'
添加后使用pod repo
命令查看:
使用CocoaPods
建立一个模板工程:
pod lib create Playground
What platform do you want to use?? [ iOS / macOS ]
> ios
What language do you want to use?? [ Swift / ObjC ]
> swift
Would you like to include a demo application with your library? [ Yes / No ]
> yes
Which testing frameworks will you use? [ Quick / None ]
> none
Would you like to do view based testing? [ Yes / No ]
> no
……这里是编码过程……
编码完成后,我们来编辑Playground.podspec
文件:
#
# Be sure to run `pod lib lint Playground.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 https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'Playground' # 组件名称
s.version = '0.1.0' # 组件当前版本
s.summary = 'A short description of Playground.'
# 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 = '代码仓库地址'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'trimaximus' => 'trimaximus9@gmail.com' }
s.source = { :git => '代码仓库地址.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '8.0' #适配最低系统版本
s.source_files = 'Playground/Classes/**/*'
# s.resource_bundles = {
# 'Playground' => ['Playground/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
接下来验证该组件是否可用:
pod lib lint --allow-warnings
若通过验证,则将其推送到某个代码仓库,注意,这里是组件本身的代码仓库,而不是podspec
索引仓库,并为其打上tag
,并推送到远程仓库:
git tag -m "Release 0.1.0" 0.1.0
git push --tags
接下来就到了最后一步,将podspec
文件推送到组件仓库中:
pod repo push UtopiaPods Playground.podspec --allow-warnings
最后再使用pod repo update
+pod search Playground
验证:
P.S.相对于整个文集,这篇文章似乎有些“奇葩”了。