一、创建本地repo,并与远端repo私有索引库关联
- GitLab创建repo私有库
- 本地创建repo索引文件,并与远端关联
pod repo add MLJTestRepo http://gitlab.laodao.so/MLJLib/MLJTestRepo.git
注意:http://gitlab.laodao.so/MLJLib/MLJTestRepo.git 为gitlab自己创建的repo的git地址。
- 查看是否成功
finder 前往文件夹~/.cocoapods/repos
查看自己创建的本地repo文件
二、创建本地lib库,并与远端lib私有组件库关联
-
GitLab创建lib私有库
-
本地创建lib库文件
终端进入准备创建lib的文件夹,执行命令
pod lib create MLJTestLib
之后选项配置如下:
What platform do you want to use?? [ iOS / macOS ] > iOS What language do you want to use?? [ Swift / ObjC ] > ObjC Would you like to include a demo application with your library? [ Yes / No ] > Yes Which testing frameworks will you use? [ Specta / Kiwi / None ] > None Would you like to do view based testing? [ Yes / No ] > No What is your class prefix? > MLJ
完成后会自动打开MLJTestLib对应的Example工程。
之后的组件开发将会在这个Example工程中进行,组件存放在MLJTestLib/Classes中,即Example工程中ReplaceMe.m存放位置。 -
本地lib库文件与远端lib私有库关联
在MLJTestLib.pobspec文件配置
Pod::Spec.new do |s| s.name = 'MLJTestLib' s.version = '0.1.0' s.summary = 'maolijie‘s MLJTestLib.' # 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 = 'http://gitlab.laodao.so/MLJLib/MLJTestLib' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'devmao666@gmail.com' => '2889886846@qq.com' } s.source = { :git => 'http://gitlab.laodao.so/MLJLib/MLJTestLib.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' s.ios.deployment_target = '8.0' s.source_files = 'MLJTestLib/Classes/**/*' # s.resource_bundles = { # 'MLJTestLib' => ['MLJTestLib/Assets/*.png'] # } # s.public_header_files = 'Pod/Classes/**/*.h' # s.frameworks = 'UIKit', 'MapKit' # s.dependency 'AFNetworking', '~> 2.3' end
修改
s.homepage
为lib私有库的url,s.source
为lib私有库的git地址。另
s.summary
做适当修改,方便pod search
查找库之后的辨识。 -
对修改的podspec文件本地验证
终端进入podspec所在的文件夹,执行下面命令
pod lib lint
如果warning验证不通过可以加上
--allow-warnings
,即pod lib lint --allow-warnings
。通过验证会提示
xxx passed validation.
-
本地lib库上传到远端lib私有库
终端进入lib库所在的文件夹,执行下面命令:
git init git remote add origin http://gitlab.laodao.so/MLJLib/MLJTestLib.git git add . git commit -m "Initial commit" git push -u origin master
git init
初始化本地仓库
git add .
增加文件到缓存区
git commit -m '初始化'
从缓存区提交到本地仓库
git push -u origin master
合并到主分支
三、打tag 发版本
设定本地lib库的tag为podspec的version值,并推送到远端,同步远端lib库的tag值
git tag 0.1.0
git push --tags
pod spec lint
git tag 0.1.0
本地lib库打tag值为podspec的0.1.0
git push --tags
将tag值推到远端,同步远端lib库
git spec lint
校验远端podspec文件
四、podspec文件上传到远端私有repo库
pod repo push MLJTestRepo MLJTestLib.podspec
MLJTestRepo
本地repo文件名
MLJTestLib.podspec
lib库的索引文件名
参考
-
从零用CocoaPods创建私有索引库
组件化基础操作,描述详尽,准确。
补充:unable to find utility "simctl"的解决方案 -
iOS组件化探究之私有库的创建
带gif,非常详尽,以码云为例。 -
组件化架构漫谈
深度好文,对比了蘑菇街与天猫组件化方案,侧重于项目架构。
网友评论