标签:分享 添加 create desc type efi only work 项目版本
创建一个私有的podspec包括如下那么几个步骤:
本地私有仓库:
什么是Spec Repo?他是所有的Pods的一个索引,就是一个容器,所有公开的Pods都在这个里面,他实际是一个Git仓库,remote端在GitHub上,当我们使用Cocoapods后它会被clone到本地的~/.cocoapods/repos目录下,可以进入到这个目录看到master文件夹就是这个官方的Spec Repo了。这个master目录的结构是这个样子的。
1.在码云上创建一个私有库:
https://gitee.com/Steven_Hu/HKCommonTools.git
2.将私有库添加到本地
pod repo add REPO_NAME SOURCE_URL
$pod repo add CommomToolSpec https://gitee.com/Steven_Hu/HKCommonTools.git
Cloning spec repo `CommomToolSpec` from `https://gitee.com/Steven_Hu/HKCommonTools.git`
3.cd 到桌面开始组件化抽取
cd ./Desktop
pod lib create HKCommonTool
Cloning `https://github.com/CocoaPods/pod-template.git` into `HKCommonTool`. Configuring HKCommonTool template. ! Before you can create a new library we need to setup your git credentials. What is your email? > 916109796@qq.com ! Setting your email in git to 916109796@qq.com git config user.email "916109796@qq.com" ------------------------------ To get you started we need to ask a few questions, this should only take a minute. If this is your first time we recommend running through with the guide: - https://guides.cocoapods.org/making/using-pod-lib-create.html ( hold cmd and double click links to open in a browser. ) 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 ] > Yes What is your class prefix? > HK Running pod install on your new library. Pod installation complete! There are 2 dependencies from the Podfile and 1 total pods installed.
把要抽取的工具类拖到 Pods ->Development Pods 下的Replace.m 中并替换掉它。
cd 到工程目录下 执行 pod install
4.推送到远程私有库(git远程仓库地址,或者码云等)
//关联远程仓库
在 HKCommonTool 工程目录下 执行:
$git remote add origin https://gitee.com/Steven_Hu/HKCommonTools.git
//提交到git仓库
git add . git commit -m ‘HKCommonTool初始化‘ git push origin master git push origin master -f //全局提交
5.修改 .podspec 文件并提交
Pod::Spec.new do |s| #名称 s.name = ‘HKCommonTool‘ #版本号 s.version = ‘0.1.0‘ #摘要 s.summary = ‘HKCommonTool 常用工具类归类‘ #描述 s.description = ‘iOS开发常用的常用宏定义和工具类,网络框架等~‘ #远程仓库首页链接 s.homepage = ‘https://gitee.com/Steven_Hu/HKCommonTools‘ #截图 # s.screenshots = ‘www.example.com/screenshots_1‘, ‘www.example.com/screenshots_2‘ #许可证 s.license = { :type => ‘MIT‘, :file => ‘LICENSE‘ } #作者 s.author = { ‘HJT916109796‘ => ‘916109796@qq.com‘ } #source来源 s.source = { :git => ‘https://gitee.com/Steven_Hu/HKCommonTools.git‘, :tag => s.version.to_s } #社交链接 # s.social_media_url = ‘https://twitter.com/<TWITTER_USERNAME>‘ #开发版本 s.ios.deployment_target = ‘9.0‘ #资源文件路径 s.source_files = ‘HKCommonTool/Classes/**/*‘ #资源包 # s.resource_bundles = { # ‘HKCommonTool‘ => [‘HKCommonTool/Assets/*.png‘] # } # s.public_header_files = ‘Pod/Classes/**/*.h‘ # s.frameworks = ‘UIKit‘, ‘MapKit‘ # s.dependency ‘AFNetworking‘, ‘~> 2.3‘ end
校验文件的正确性:
$pod lib lint HKCommonTool.podspec
重新提交:
git add . git commit -m ‘修改podspec文件~‘ git push origin master
设置tag
git tag git tag ‘0.1.0‘ git push --tags
6.推送本地Spec到远程仓库
git fetch origin master
git checkout master
git branch --set-upstream-to=origin/master master
Branch ‘master‘ set up to track remote branch ‘master‘ from ‘origin‘.
git pull
pod repo update
pod repo push CommomToolSpec HKCommonTool.podspec
git push
git pull
git push origin master
7.如何使用:
编辑Podfile文件如下:
编辑Podfile 必须加 git => ‘https://gitee.com/Steven_Hu/HKCommonTools.git‘
platform :ios, ‘9.0‘ use_frameworks! target ‘HKTools‘ do pod ‘XCDemo‘ ,:git => ‘https://gitee.com/Steven_Hu/XCTool.git‘ pod ‘HKCommonTool‘ ,:git => ‘https://gitee.com/Steven_Hu/HKCommonTools.git‘ # pod ‘HKTools‘, :path => ‘./Lib/HKTools‘ # pod ‘HKTools‘, :podspec => ‘~/.cocoapods/repos/HKTools/HKTools.podspec‘ end
8.其他常用命令:
删除本地私有库:
$ pod repo remove hktools
Removing spec repo `gitee-steven_hu-hktools`
组件化开发-002-Cocoapods远程私有库使用(Private Repo)
标签:分享 添加 create desc type efi only work 项目版本
原文地址:https://www.cnblogs.com/StevenHuSir/p/ComponentBased_PrivateRepo.html