cocoa gitee私库搭建

其他文章其实已经有介绍私库搭建的,但是在参照搭建过程中发现一些不匹配的问题点(照着做走不通),特写文章记录。

<1>创建 repo 私有库的索引库 spec

在git上创建索引库  spec,我这儿用码云举例,方法和创建项目是一样的。

截屏2022-05-12 下午1.48.44.png

然后就有了索引库的地址:https://gitee.com/*******/test-module-specs.git

截屏2022-05-12 下午1.53.59.png

将索引库添加到本地仓库

// pod repo add specs库名 specs库地址pod repoaddTestModuleSpecshttps://gitee.com/******/test-module-specs.git

查看是否添加成功

pod repo list//可以看到已经添加成功TestModuleSpecs-Type:git(master)-URL:https://gitee.com/*********/test-module-specs.git-Path:/Users/*******/.cocoapods/repos/TestModuleSpecs

<2>创建私有库并发布到索引库

第一步:先在git上创建私有库,还是以码云举例。

然后就有了私有库地址:

https://gitee.com/*************/test-module-one.git

第二步:创建私有库模板

//创建私有库模板pod lib create TestModuleOne//下面是私有库的简单配置//选择平台What platformdoyou want to use??[iOS/macOS]>ios//选择编程语言What languagedoyou want to use??[Swift/ObjC]>objc//选择是否创建测试demoWould you like to include a demo applicationwithyourlibrary?[Yes/No]>yes//选择测试框架Which testing frameworks will you use?[Specta/Kiwi/None]>none//是否视图测试Would you like todoview based testing?[Yes/No]>no//类前缀Whatisyourclassprefix?>LU

这就得到了库模板:

这就创建好了私有库模块了

编辑私有库索引 TestModuleOne.podspec

version            功能版本,建议和tag保持一致,版本从0.1.0开始。summary            功能概要,需要填写更新,否则lint检测无法通过。description        功能描述,可以选择性删除,否则lint检测无法通过。homepage            资源首页,私有库对应的浏览器地址。resource            资源地址,git克隆地址。建议使用http/https,git类型有权限控制。source_file        类资源文件,默认Classes下的所有文件,放置私有库核心文件。resourcesBundle资源文件(不推荐使用),会合并至MainBundle中,访问便利,但会存在命名冲突问题。个别SDK必须放在MainBundle中才能使用,比如微博SDK!!!。resource_filesBundle资源文件(推荐使用),单独的Bundle文件,不与MainBundle合并,使用内部资源时和MainBundle路径有区别!!!。exclude_files      指定不被包含的文件、目录vendored_libraries  内部包含的.a静态库 例如'ModuleName/Classes/Lib/*.{a}'vendored_framework  内部包含的.framework静态库 例如'ModuleName/Classes/Framework/***.framework'static_framework    指定pod加静态库标签true/false指定支持的架构,如果因为i386等架构问题lint检测不通过,可以在检测时添加--skip-import-validation参数s.xcconfig={'VALID_ARCHS'=>'armv7 arm64e armv7s arm64 x86_64',}如果支持单文件目录下的文件引用,可以设置subspecs.default_subspec='Core's.subspec'Core'do|core|core.dependency'MBProgressHUD'core.source_files="DYFoundationFramework/Classes/**/*.{h,m}"ends.subspec'OldCommonTools'do|oct|oct.dependency'SAMKeychain'oct.source_files="DY****Framework/Classes/Object-C/DY****Tools/**/*.{h,m}"end

截屏2022-05-12 下午2.35.28.png

验证.podspec文件的格式是否正确

pod lib lint//本地验证pod能否通过验证,如果失败使用下面命令: pod lib lint --verbose查看原因,或者使用pod lib lint --allow-warnings忽略警告错误

将私有库代码提交到git

git remoteaddorigin https://gitee.com/********/test-module-one.gitgitadd.git commit-a-m"第一次提交 版本为0.1.0"git pull origin master--allow-unrelated-historiesgit push-f origin mastergit tag0.1.0git push origin0.1.0

podspec文件中的地址要和远程仓库保持一致

git push -f origin master,本地强制上传到远程,把远程的覆盖,这儿是第一次上传,所有就用本地代码覆盖掉远端代码了。

这儿就已经吧私有库代码提交到git上了

第三步:将私有库发布

//pod repo push 索引库名 私有库.podspecpod repo pushTestModuleSpecsTestModuleOne.podspec--allow-warnings//检查一下是否成功pod search TestModuleOne->TestModuleOne(0.1.0)Ashortdescription of TestModuleOne.pod'TestModuleOne','~> 0.1.0'-Homepage:https://gitee.com/********/test-module-one-Source:https://gitee.com/******/test-module-one.git-Versions:0.1.0[TestModuleSpecsrepo]

这就算是搭建完成了

作者:LUJQ

链接:https://www.jianshu.com/p/156cff56a91d

来源:

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

你可能感兴趣的:(cocoa gitee私库搭建)