CocoaPods 私有源配置

1:準(zhǔn)備工作: via:如何創(chuàng)建私有podspec

; 創(chuàng)建 私有源 庫(kù)
http://123.103.86.53:8090/zhuantiku/ZTKIOSArenaCentre-Spec.git

: 創(chuàng)建 代碼庫(kù)
http://123.103.86.53:8090/zhuantiku/ZTKIOSArenaCentre-Repo.git

2:本地添加私有源

pod repo add ZTKIOSArenaCentre-Spec http://123.103.86.53:8090/zhuantiku/ZTKIOSArenaCentre-Spec.git

存放 Spec 版型信息

3: 創(chuàng)建pod

pod lib create ZTKIOSArenaCentre-Repo

注意:先驗(yàn)證

4: 配置 代碼倉(cāng)庫(kù) 和 podspec 將代碼同步到此Git上

git add .

git commit -m "Init"

git remote add origin http://123.103.86.53:8090/zhuantiku/ZTKIOSArenaCentre-Repo.git

git push --set-upstream origin master

編輯podspec 和 pod/class 完成后執(zhí)行
1:pod lib lint --allow-warnings
驗(yàn)證 pod 和 podspec代碼是否編譯通過(guò)

2: 私有庫(kù)引用私有庫(kù)

pod spec lint --sources='http://123.103.86.53:8090/zhuantiku/ZTKIOSDevFramework-Spec.git,https://github.com/CocoaPods/Specs' --allow-warnings --use-libraries --verbose
pod repo push 本地repo名 podspec名 --sources='私有倉(cāng)庫(kù)repo地址,https://github.com/CocoaPods/Specs'

5: 將改動(dòng)代碼 提交 repo 庫(kù)

git add .
git commit -m '編輯.podspec and Example and Pod Class'
//添加tag 一定要和podspec中的version一致
git tag 0.0.1
git push origin master --tags

6: 把Spec 添加到準(zhǔn)備工作中的私有源倉(cāng)庫(kù)(ZTKIOSArenaCentre-Spec)

pod repo push 
ZTKIOSDevFramework-Repo  ZTKIOSDevFramework-Repo.podspec --allow-warnings --use-libraries --verbose
pod repo push 
ZTKIOSArenaCentre-Spec ZTKIOSArenaCentre-Repo.podspec --sources='http://123.103.86.53:8090/zhuantiku/ZTKIOSDevFramework-Spec.git,https://github.com/CocoaPods/Specs'  --allow-warnings --use-libraries
--verbose
pod repo push 本地repo名 podspec名 --sources='私有倉(cāng)庫(kù)repo地址,https://github.com/CocoaPods/Specs'

7: 查 pod

pod search ZTKIOSDevFramework-Repo  

8:進(jìn)入需要使用 ZTKRepoSpec 的項(xiàng)目中配置 Podfile

use_frameworks!
source 'https://github.com/CocoaPods/Specs.git' #官方倉(cāng)庫(kù)地址
source ‘http://123.103.86.53:8090/zhuantiku/ZTKIOSDevFramework-Spec.git’  #私有倉(cāng)庫(kù)地址(spec)
target 'ZTKIOSDevFramework-Repo_Example' do
    pod 'MJExtension'
    pod 'CocoaAsyncSocket'
    pod 'pop', '~> 1.0'
    pod 'SDAutoLayout', '~> 2.1.3'
    pod 'ZTKIOSDevFramework-Repo' , '0.2.0'
    pod 'SDWebImage'
end

然后

pod update
pod install

1:pod 文件 無(wú)法#import
在build settings -->Search Paths-->User Header Search Paths
$(PODS_ROOT)
2: error: include of non-modular header inside framework module
將導(dǎo)入 第三方 不要放在.h 放在.m 文件內(nèi)

VIA: 教你如何從0到1實(shí)現(xiàn)組件化架構(gòu)

在現(xiàn)有工程中實(shí)施基于CTMediator的組件化方案
基于 CocoaPods 和 Git 的 iOS 工程組件化實(shí)踐
wujunyang/jiaModuleDemo





待定:

3:根據(jù) gitlab 配置 代碼repository (repo spec 都要init)
iOS模塊化實(shí)踐 -- 利用CocoaPods拆分項(xiàng)目

cd 代碼repository
git init
git add .
git commit -m "first commit"
git remote add origin http://123.103.86.53:8090/zhangxinxin/ZTKDevFramework.git
git push -u origin master

4: 配置 podspec文件 via:[CocoaPods 項(xiàng)目 “模塊化” 實(shí)戰(zhàn)] (這個(gè)全)(http://www.itdecent.cn/p/247ec798cce1)

因cocoaPods強(qiáng)制添加開源許可文件,在ZTKDevFramework工程目錄下創(chuàng)建FILE_LICENSE

echo MIT>FILE_LICENSE

創(chuàng)建podspec文件

pod spec create ZTKIOSDevFramework-Repo 
Pod::Spec.new do |s|
s.name             = 'ZTKIOSDevFramework-Repo '
s.version          = '0.1.0'
s.summary          = '管理公司項(xiàng)目中通用代碼的 Pods 庫(kù)'
s.homepage         = 'http://www.demo.com/'
s.license          = { :type => 'MIT', :file => 'LICENSE' }   # 開源協(xié)議
s.author           = { 'KentonYu' => 'demo@163.com' }
s.source           = { :git => 'http://123.103.86.53:8090/zhangxinxin/ZTKDevFramework.git', :tag => s.version.to_s }   # Pods 庫(kù)的地址
s.ios.deployment_target = '7.0'   # Pods 庫(kù)支持的系統(tǒng)版本

s.prefix_header_contents = '#import "DTBaseKit.h"'    # Pods 庫(kù)中需要預(yù)編譯的頭文件


# subspec 是 Spec 中的子類
s.subspec 'BaseKit' do |sub|
sub.source_files = 'PodsRepo/BaseKit/*.{h,m}', 'PodsRepo/BaseKit/**/*.{h,m}'
sub.public_header_files = 'PodsRepo/BaseKit/*.h', 'PodsRepo/BaseKit/**/*.h'
end

s.subspec 'NetworkingKit' do |sub|
sub.source_files = 'PodsRepo/NetworkingKit/*.{h,m}'
sub.public_header_files = 'PodsRepo/NetworkingKit/*.h'
sub.dependency 'AFNetworking', '~> 3.1.0'
sub.dependency 'PodsRepo/BaseKit'    # 可以依賴同一個(gè) Pods 庫(kù)中的 subspec
end

# s.resource_bundles = {    # 依賴的資源路徑
#   'PodsRepo' => ['PodsRepo/Assets/*.png']
# }

# s.frameworks = 'UIKit', 'MapKit'   # 依賴的系統(tǒng)庫(kù)
end

s.source_files = "Base", "BaseViewController/*/.{h,m}"
s.source_files 這個(gè) 如果pod 有多個(gè)文件夾怎么辦?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容