最近更新 2023.3.31
私有Cocoapods倉庫&遇到的問題
pod索引庫
私有pod倉庫
pod組件化
pod遇到的問題
Git代碼搬遷
在新Git服務(wù)器創(chuàng)建需要遷移的同名空項目(不同名也可以)
Git clone 舊Git代碼到本地 (或者本地有Git origin的代碼乓梨,用Git remote -v 查看)
Git push --mirror 新的空項目地址
完成后Git clone 新Git上的代碼到本地game over
Pod 私有庫(子組件)
1. 創(chuàng)建工程以YBBluetoothKit
為例
pod lib create YBBluetoothKit
#然后回答幾個問題
#選擇平臺
What platform do you want to use?? [ iOS / macOS ]
> ios
#選擇語言
What language do you want to use?? [ Swift / ObjC ]
> swift
#是否需要Demo
Would you like to include a demo application with your library? [ Yes / No ]
> yes
#是否使用測試工具
Which testing frameworks will you use? [ Quick / None ]
> none
#是否進行視圖測試
Would you like to do view based testing? [ Yes / No ]
> no
2. 設(shè)置podspec 文件
注意必須修改的內(nèi)容
Pod::Spec.new do |s|
# 庫名稱,默認(rèn)和工程名相同径荔,建議不改
s.name = 'YTPrivateBaseKit'
# 庫的版本,每次升級版本后必須要在這里修改版本號
s.version = '0.1.0'
# 該庫的簡介脆霎,更改成適合的簡介总处,使用默認(rèn)簡介會出現(xiàn)簡介沒有意義的錯誤
s.summary = '這是一個藍(lán)牙庫.'
# 詳細(xì)描述,一般不用改睛蛛,有readme呢
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
# 庫的主頁鹦马,需要更改為正確的主頁
s.homepage = 'http://101.132.74.65/fengming/YBBluetoothKit'
# 許可,私有庫可以不改
s.license = { :type => 'MIT', :file => 'LICENSE' }
# 作者忆肾,可以不改
s.author = { 'fengming' => '1028708571@qq.com' }
# 庫的克隆地址荸频,這個地址必須改成正確的克隆地址,可以是 https 或 ssh
s.source = { :git => 'http://101.132.74.65/fengming/YBBluetoothKit.git', :tag => s.version.to_s }
# 該庫最低支持版本客冈,可以修改為對應(yīng)版本
s.ios.deployment_target = '10.0'
# 該庫上傳文件的路徑旭从,默認(rèn)是 Classes 文件夾下的所有文件夾及文件,默認(rèn)不需要改
s.source_files = 'YBBluetoothKit/Classes/**/*'
#--------------------------------------------------
# 以下是默認(rèn)沒有但可以自行添加的基礎(chǔ)配置
# 設(shè)置指定版本號或非指定版本號的依賴庫场仲,
#s.dependency 'SnapKit'
# 指定 Swift 語言版本和悦,Swift 項目需要設(shè)置這個
# s.swift_version = '4.2'
end
5.本地校驗pod lib lint
cd 到Y(jié)BBluetoothKit => YBBluetoothKit.podspec 所在目錄
pod lib lint --allow-warnings
出現(xiàn)YBBluetoothKit passed validation.
表示成功
6. 創(chuàng)建遠(yuǎn)程庫
在Git遠(yuǎn)端創(chuàng)建項目
7. 關(guān)聯(lián)遠(yuǎn)程庫
git remote add origin "http://101.132.74.65/fengming/YBBluetoothKit"
8.提交代碼并為項目打上tag
git add .
git commit -m "project init"
git tag -m "first dev v0.1.0" 0.1.0
git push
git push --tags
9 .聯(lián)網(wǎng)校驗pod spec lint
Pod 索引庫(主倉庫)
如果已經(jīng)創(chuàng)建過,就不需要再創(chuàng)建了
1. 在Git遠(yuǎn)端創(chuàng)建主工作項目 以ManagerSpecRepo
為例
創(chuàng)建一個空的遠(yuǎn)端項目即可
2. 將索引庫添加(關(guān)聯(lián))到CocoaPods的目錄下
pod repo add ManagerSpecRepo http://101.132.74.65/fengming/ManagerSpecRepo
3.將子組件YBBluetoothKit.podspec
添加并推送到ManagerSpecRepo
主倉庫
pod repo push ManagerSpecRepo YBBluetoothKit.podspec
查看本地索引庫
pod repo list
刪除本地索引庫
pod repo remove name
Pod私有庫更新流程
將修改過的子組件文件的.podspec文件渠缕,修改version即可
打tag鸽素,并將tag上傳 (git push origin [tagname] / git push origin --tags)
pod lib lint --allow-warnings
pod repo push 主倉庫 子組件.podspec --verbose --allow-warnings
如果有.a都靜態(tài)庫使用
--use-libraries
pod repo push ManagerSpecRepo YBBluetoothKit.podspec --verbose --use-libraries --allow-warnings
- 如果里面已經(jīng)依賴了其他私有庫 需要指定 sources 地址(以逗號隔開)
pod repo push ManagerSpecRepo YBBluetoothKit.podspec --verbose --use-libraries --allow-warnings --sources="http://101.132.74.65/fengming/ManagerSpecRepo,https://github.com/CocoaPods/Specs.git"
Pod私有庫異常整理
1. pod lib lint (檢查本地pod)
[!] DemoPodSpecs did not pass validation, due to 2 warnings (but you can use --allow-warnings to ignore them).
You can use the --no-clean option to inspect any issue.
解決辦法:用 pod lib lint --allow-warnings 命令
2. pod spec lint (檢查遠(yuǎn)程pod)
Encountered an unknown error (Simulator is not available.) during validation
解決辦法:升級cocoapods sudo gem install -n /usr/local/bin cocoapods --pre
3. pod spec lint (檢查遠(yuǎn)程pod)
[iOS] unknown: Encountered an unknown error (Must be in the root of the repo (/Users/*.cocoapods/repos/master), instead in ....
解決辦法:可能是因為更新完Xcode以后Xcode路徑更改了,Xcodebuild找不到路徑亦鳞。 執(zhí)行命令 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
4. pod repo push DemoPodSpecs DemoPodSpecs.podspec
The DemoPodSpecs.podspec
specification does not validate.
解決辦法: pod repo push DemoPodSpecs DemoPodSpecs.podspec --verbose --use-libraries --allow-warnings
5. pod repo push DemoPodSpecs DemoPodSpecs.podspec --verbose --use-libraries --allow-warnings
/usr/bin/git -C /Users/.cocoapods/repos/DemoPodSpecs -C
/Users/.cocoapods/repos/DemoPodSpecs push origin master
fatal: repository '' not found
解決辦法:到 /Users/.cocoapods/目錄下查看私有pod庫是否存在
6. pod lib lint
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: `echo "2.3" > .swift-version`.
解決辦法:運行 echo 4.2 > .swift-version
7. Pod install
7.1
[!] CocoaPods could not find compatible versions for pod "YBCoreKit":
In snapshot (Podfile.lock):
YBCoreKit (= 1.2.1)
In Podfile:
YBSDKPayKit (from ../) was resolved to 1.8.1, which depends on
YBCoreKit
It seems like you've changed the constraints of dependency YBCoreKit inside your development pod YBSDKPayKit.
You should run pod update YBCoreKit to apply changes you've made.
解決辦法:
- 注釋掉source馍忽,和所以pod 庫,以及pod 'demo', :path => '../'燕差,然后
pod install
- 重新打開注釋掉的內(nèi)容遭笋,然后
pod install
7.2 Unable to find a specification for ""
解決辦法:
別著急pod update
一下就好了