闲来没事,整理好久之前的文档。制作私有库和公共库还是有一定的差别的。甚至还有快速模式,后面给大家展开叙述
1:创建两个远程仓库
- 创建ios_spece远程仓库,用来存放本地podspec。
- 创建podProject远程仓库,用来存放项目工程文件。
2:处理ios_spece远程仓库
前往文件夹 ~/.cocoapods/repos
打开终端,在终端切换到当前目录下,然后进行pod repo add操作
在终端输入:
pod repo add ios_spece https://gitee.com/whuizhou/i-os_speace.git
(1中创建的ios_spece远程仓库的地址)
3:创建pod的项目工程
3.1 修改podspec文件
Pod::Spec.new do |s|
s.name = 'shareSDK'
s.version = '1.0.0'
s.summary = 'SHARE-SDK'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://gitee.com/whuizhou'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { '大哥还是当年的大哥' => 'wangh@email.com' }
s.source = { :git => 'https://gitee.com/whuizhou/repo-share-p.git', :tag => s.version.to_s }
#*** 这里一定要修改为工程的git地址
s.ios.deployment_target = '9.0'
s.source_files = 'shareSDK/Classes/**/*'
# s.resource_bundles = {
# 'shareSDK' => ['shareSDK/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking'
s.dependency 'SDWebImage'
end
设置初始版本为1.0.0
引用了SDWebImage
3.2 校验本地podspec文件
到工程的目录下,验证podspec文件
pod lib lint shareSDK.podspec --allow-warnings --verbose
验证结果
** BUILD SUCCEEDED **
Testing with `xcodebuild`.
-> shareSDK (1.0.2)
- NOTE | xcodebuild: note: Using new build system
- NOTE | xcodebuild: note: Building targets in parallel
- NOTE | xcodebuild: note: Using codesigning identity override: -
- NOTE | xcodebuild: note: Build preparation complete
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Analyzing workspace
- NOTE | [iOS] xcodebuild: note: Constructing build description
- WARN | xcodebuild: /Users/zzg/Library/Developer/Xcode/DerivedData/App-gjchcgjwyytzwnbeodicecfxkczb/Build/Products/Release-iphonesimulator/shareSDK/shareSDK.framework/Headers/shareSDK-umbrella.h:13:9: warning: double-quoted include "LogTool.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
shareSDK passed validation.
3.3 本地文件上传到远程仓库中,并打对应的tag号
- 上传本地工程到远端仓库
- 打
tag
版本号,一定要与s.version 一致
s.version = '1.0.0'
打tag
// 打tag号
git tag -m "1.0.2标签" -a 1.0.2
// 推送tag
git push --tags
// 查看tag
git tag
- 检验podspecs文件的有效性
pod lib lint /Users/zzg/Desktop/SHARE/shareSDK.podspec --use-libraries --allow-warnings
校验结果如下
-> shareSDK (1.0.2)
- NOTE | xcodebuild: note: Using new build system
- NOTE | xcodebuild: note: Building targets in parallel
- NOTE | xcodebuild: note: Using codesigning identity override: -
- NOTE | xcodebuild: note: Build preparation complete
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Analyzing workspace
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
shareSDK passed validation.
4:向私有的ios_space远程仓库提交podspec
pod repo push ios_speace shareSDK.podspec --sources='https://gitee.com/whuizhou/i-os_speace.git,https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' --use-libraries --allow-warnings --verbose
如果引用的有其他第三方库,或者其他私有地址一定要在后面写上
source='地址' --use-libraries --allow-warnings --verbose
这里用的是清华源
5:使用自己的私有库
在工程的podfile文件的头一行里写
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
source "https://gitee.com/whuizhou/i-os_speace.git"
完成podfile文件如下
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
source "https://gitee.com/whuizhou/i-os_speace.git"
target 'dddd' do
platform :ios, '9.0'
pod 'shareSDK', '~> 1.0.2'
end