一、在内网 Git 创建一个空的仓库,用来存放私有库信息
名称为 SpecRepo(名字可以自己定)。

二、把内网仓库 SpecRepo 添加到CocoaPods本地仓库。
这步操作会在 ~/.cocoapods/repo 路径下创建一个名字为 SpecRepo 的空文件夹。
pod repo add SpecRepo http://192.168.1.168/iOS/SpecRepo.git

三、写一个xx库,提交到内网Git
podspec文件创建并通过校验
……(略)
四、添加私有库到 SpecRepo
pod repo push SpecRepo xxxx.podspec
如果有警告,会导致无法通过,需要添加--allow-warnings
如果使用了 C 函数相关的,需要添加--use-libraries
额外问题:
如果导入的私有库有动态库/静态库,有些C++的代码会导致pod命令编译找不到头文件问题,而真机调试却正常。

解决:
--skip-import-validation
// 本地检测
pod lib lint xxxx.podspec
// 推送到私有库
pod repo push SpecRepo xxxx.podspec
// --skip-import-validation
// 本地检测
pod lib lint xxxx.podspec --skip-import-validation
// 推送到私有库
pod repo push SpecRepo xxxx.podspec --skip-import-validation

五、使用
在 podfile 文件中添加 source
source 'http://192.168.1.168/iOS/SpecRepo.git'
source 'https://github.com/CocoaPods/Specs.git'
target 'xxxx' do
pod 'xxxx'
end
网友评论