1,首先你得有自己的框架工程,接著,才創(chuàng)建一個(gè)模版podspec文件及其相關(guān)文件夾,
命令:
? ? ? pod lib create? 私有庫名B
大概目錄如下:

????進(jìn)入到該私有庫項(xiàng)目路徑中,將framework動(dòng)態(tài)組件庫的代碼文件?拷貝到?Classes文件夾中;
2,根據(jù)你的框架需要,修改.podspec文件?的內(nèi)容:
Pod::Spec.new do |s|
? s.name? ? ? ? ? ? = 'EKUIBaseKitSpec'
? s.version? ? ? ? ? = '0.2.6'
? s.summary? ? ? ? ? = 'A short description of EKUIBaseKitSpec.'
# This description is used to generate tags and improve search results.
? s.description? ? ? = <<-DESC
TODO: Add long description of the pod here.
?? ? ? ? ? ? ? ? ? ? ? DESC
? s.homepage? ? ? ? = 'https://github.com/tianlunyuche/EKUIBaseKitSpec'
? # s.screenshots? ? = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
? s.license? ? ? ? ? = { :type => 'MIT', :file => 'LICENSE' }
? s.author? ? ? ? ? = { 'tianlunyuche' => 'xin@moy.com' }
? s.source? ? ? ? ? = { :git => 'root@172.0.0.0:/home/ios/toollib/EKUIBaseKitSpec.git',
?? ? ? ? ? ? ? ? ? ? ? ? :tag => s.version.to_s,
?? ? ? ? ? ? ? ? ? ? ? ? :submodules => true
? }
? s.ios.deployment_target = '8.0'
? s.requires_arc = true? #是否支持arc
? #s.public_header_files = 'EKUIBaseKitSpec/Classes/**/*.h'
? #全局文件
? #s.prefix_header_contents = '#import "Masonry.h"', '#import "NSString+Helper.h"'
? s.prefix_header_file = 'EKUIBaseKitSpec/Classes/EKWHeader.h'
? # s.resource_bundles = {
? #? 'EKWUIBase' => ['EKWUIBase/Assets/*.png']
? # }
? s.frameworks = 'UIKit', 'Foundation'
? # s.dependency 'AFNetworking', '~> 2.3'
? s.dependency 'Masonry'
? s.source_files = 'EKUIBaseKitSpec/Classes/**/*'
? s.subspec 'Category' do |a|
? ? ? a.source_files = 'EKUIBaseKitSpec/Classes/Category/**/*'
? end
? s.subspec 'EKWTextField' do |b|
? ? ? b.source_files = 'EKUIBaseKitSpec/Classes/EKWTextField/**/*'
? ? ? b.dependency 'EKUIBaseKitSpec/Category'
? end
? s.subspec 'EKWUnitField' do |c|
? ? ? c.source_files = 'EKUIBaseKitSpec/Classes/EKWUnitField/**/*'
? ? ? c.dependency 'EKUIBaseKitSpec/Category'
? end
end
3,然后創(chuàng)建一個(gè)shell腳本文件,取名0.0.1.sh,0.0.1是tag的版本號(hào),跟podspec文件里的tag版本號(hào)一致,每次版本更新都要修改。
執(zhí)行腳本:./0.0.1sh (第一次需要修改權(quán)限,輸入linux命令:chmod 755 0.0.1.sh)
腳本具體內(nèi)容如下:
#!/bin/sh
read -p "是否已用版本號(hào)重命名腳本名?[y/n]" input
case$inputin
[yY]*)
echo "命名版本號(hào)finished"
;;
[nN]*)
echo "改名字去!"
exit
;;
*)
echo "Just enter y or n, please."
exit
;;
esac
my_name=${0##*/}
tag_name="${my_name%.*}"
your_lib_pash=$(cd'dirname $0'; pwd)
echo ${your_lib_pash}
your_lib_name="${your_lib_pash##*/}"
if [ ! -d "/Users/${USER}/.cocoapods/repos/ekw" ]
then
pod repo add ekw? root@172.17.0.0:/home/ios/toollib/EkwSpecs.git
fi
cd /Users/${USER}/.cocoapods/repos/ekw
git add .
git commit -m"避免前置沖突"
git pull
git push
if [ ! -d "/Users/${USER}/.cocoapods/repos/ekw/${your_lib_name}" ]
then
mkdir ${your_lib_name}
fi
if[[ $? !=0]]
then
echo "新建索引父級(jí)目錄失敗,打印文件名是${your_lib_name}"
exit
fi
if [ -d "/Users/${USER}/.cocoapods/repos/ekw/${your_lib_name}/${tag_name}" ]
then
echo "${tag_name} 版本已存在!"
exit
fi
cd ${your_lib_name}
mkdir ${tag_name}
cp "${your_lib_pash}/${your_lib_name}.podspec" "/Users/${USER}/.cocoapods/repos/ekw/${your_lib_name}/${tag_name}/${your_lib_name}.podspec"
git add .
git commit -m "版本 ${tag_name} 索引提交"
# git pull
git push
if[[ $? !=0]]
then
echo "版本索引push失敗"
else
echo "版本索引push成功"
fi
cd ${your_lib_pash}
git add .
git commit -m "版本 ${tag_name}: 新代碼提交"
#git pull
git push origin master
git tag ${tag_name}
git push --tags
pod repo update /Users/${USER}/.cocoapods/repos/ekw
if[[ $? !=0]]
then
echo "repo更新失敗"
else
echo "repo更新成功"
fi
4,最后就是驗(yàn)證安裝過程了,在自己工程的podfile文件中:
引入自己的私有庫路徑所在的源:
source 'root@172.0.0.0:/home/ios/toollib/EkwSpecs.git'
和
? ? pod'EKUIBaseKitSpec/EKWTextField'
? ? pod'EKUIBaseKitSpec/EKWUnitField'
在終端輸入命令,安裝:
pod install
5,下次修改了這個(gè)框架的代碼,要升級(jí)了,就修改腳本文件為0.0.2.sh,podspec文件里的tag版本號(hào)也為0.0.2,再次執(zhí)行腳本:
./0.0.2.sh
返回更新成功了
輸入git fetch --tag
和git tag 也返回對(duì)應(yīng)的tag了
接下來,就是更新本地的緩存庫了,pod update??EKUIBaseKitSpec
最后?。。。?!就是祝賀大家成功接入了哈哈,是不是用shell腳本后 特別簡(jiǎn)單了,每次更新庫,再也不用寫哪那么多命令行了。
給個(gè)可能用到的命令:
刪除遠(yuǎn)程標(biāo)簽:
git push origin :refs/tags/標(biāo)簽名
再重新打:
git tag‘0.1.0‘
git push —tags