GitLab创建私有库-简单版
创建私有库:1.代码库,存放代码。2.Spec库,存放podSpec文件
一、创建Spec库
1. gitlab上创建仓库,拿到仓库地址(https://git.com/user/Specs.git)
2. 克隆,生成README.md,并上传完成第一次提交
$ git clone https://git.com/user/Specs.git
$ cd Specs
$ touch README.md
$ git add .
$ git commit -m 'first commit'
$ git push origin master
3. 将该地址加入本地repo
可以起一个好记好拼的名字
$ pod repo add SomeSpecs https://git.com/user/Specs.git
使用 pod repo 查看是否添加成功
二、创建代码库
代码库创建时,最好和要封装的代码SDK同名,便于管理
1. gitlab上生成代码库,拿到代码库地址(https://git.com/user/SomeSDK.git)
2. 本地创建lib
$ pod lib create SomeSDK
$ 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 ]
> No
$ 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?
> DC
3. 将需要封装的代码,复制到(SomeSDK/SomeSDK/Classes/...)
不管是否是.h和.m文件还是.framework和.a文件,都要放到该文件夹里
封装的代码,要保证调试没有任何问题,否则在上传时会报错
4. 编辑 SomeSDK.podspec 文件
Pod::Spec.new do |s|
s.name = 'SomeSDK'
s.version = '1.0'
s.summary = 'SomeSDK.'
s.homepage = 'https://git.com/user/SomeSDK.git'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'username' => 'username@host' }
s.source = { :git => 'https://git.com/user/SomeSDK.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
#s.source_files = 'SomeSDK/Classes/**/*' //源代码形式
s.vendored_frameworks = 'SomeSDK/Classes/*.framework' //静态库形式
s.frameworks = 'UIKit', 'Foundation', 'Security', 'CoreGraphics'
#s.dependency 'AFNetworking'
end
5. 上传到代码库
$ SomeSDK git:(master) git add .
$ SomeSDK git:(master) git commit -m '1.0'
$ SomeSDK git:(master) git remote add origin https://git.com/user/SomeSDK.git
$ SomeSDK git:(master) git push -u origin master
$ SomeSDK git:(master) git tag 1.0
$ SomeSDK git:(master) git push --tags
6. 上传到源仓库 https://git.com/user/Specs.git
$ pod repo push SomeSpecs SomeSDK.podspec --allow-warnings
如果是静态库形式,后面添加 --use-libraries
$ pod repo push SomeSpecs SomeSDK.podspec --allow-warnings --use-libraries
三、静态库制作
此处省略,教程很多
注意事项:
1. 工程Scheme中: 'run' -> 'build configuration' 改成 Release。
2. 'buildSetting' 中 ,搜索 'mach', 改成 'static library',搜索 'link with standard libraries',改成 'NO'。
3. 编译模拟器framework和真机(Generic iOS Devices)framework
4. 使用 lipo -create Release-iphoneos/SomeSDK.framework/SomeSDK Release-iphonesimulator/SomeSDK.framework/SomeSDK -output SomeSDK
5. 复制Release-iphoneos/SomeSDK.framework,将刚才合并的SomeSDK,进行替换 |