iOS - 公開的 Cocoapods 倉庫創(chuàng)建(開源倉庫)

環(huán)境

CocoaPods 版本:1.15.2
芯片:Apple M1 Pro

這個(gè)場(chǎng)景月帝,我們是為了提供給所有人更加便捷的集成我們的封裝好的東西运敢。

創(chuàng)建的方式耻陕,官網(wǎng)也有介紹:https://guides.cocoapods.org/

Input:

通過命令 pod lib create 你的倉庫名稱 創(chuàng)建倉庫括眠,我這里以 lsj-FileManager 作為我的倉庫名稱

pod lib create lsj-FileManager

Output:使用的平臺(tái)

What platform do you want to use?? [ iOS / macOS ]

Input:

iOS

Output:選擇語言

What language do you want to use?? [ Swift / ObjC ]

Input:

ObjC

Output:是否創(chuàng)建演示應(yīng)用程序Demo

Would you like to include a demo application with your library? [ Yes / No ]

Input:

Yes

Output:您將使用哪些測(cè)試框架?

Which testing frameworks will you use? [ Specta / Kiwi / None ]

Input: 我個(gè)人認(rèn)為 Xcode 的 XCTest 挺好的概而,后續(xù)也可以自己加入對(duì)應(yīng)的 XCTest Target

None

Output:需要?jiǎng)?chuàng)建 UI 測(cè)試呼巷,后續(xù)也可以自行加入 Target

Would you like to do view based testing? [ Yes / No ]

Input: 是否要進(jìn)行基于視圖的測(cè)試?

Yes

Output:設(shè)置工程文件的前綴赎瑰,這個(gè)根據(jù)自己的代碼規(guī)范填寫

What is your class prefix?

Input:

L

Output:

Running pod install on your new library.

Analyzing dependencies
Downloading dependencies
Installing FBSnapshotTestCase (2.1.4)
Installing lsj-FileManager (0.1.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `lsj-FileManager.xcworkspace` for this project from now on.
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.


[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.

 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'lsj-FileManager/Example/lsj-FileManager.xcworkspace'

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `https://guides.cocoapods.org/making/making-a-cocoapod`.

到這里王悍,倉庫已經(jīng)創(chuàng)建好了,終端會(huì)打開你的項(xiàng)目

在倉庫中餐曼,添加我們的代碼

在工程的Pods/Development/Pods/lsj-FileManager/目錄下压储,有一個(gè) ReplaceMe 文件,
是存放我們文件的位置源譬,不能直接在 lsj-FileManager 右鍵 new->File集惋,
因?yàn)檫@是一個(gè)虛擬路徑,需要我們手動(dòng)導(dǎo)航進(jìn)入 Classes 目錄中瓶佳,
可以通過右鍵 ReplaceMe 文件 Show In Finder芋膘,進(jìn)入到 Classes ,獲取路徑

image

17106007320088.jpg
17106021443681.jpg

在 Example 中去使用它霸饲,Example 項(xiàng)目安裝你的pod,提供給用戶使用 Demo

Input:進(jìn)入 Example 目錄臂拓,Pod install

cd Example 
pod install

Output:

Analyzing dependencies
Downloading dependencies
Installing lsj-FileManager 0.1.0
Generating Pods project
Integrating client project
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

創(chuàng)建 Git 倉庫(備用厚脉,后續(xù)填入 .podspec 文件中的 source 字段中)

17106679122576.jpg

校驗(yàn)我們的 .podspec 文件

Input:

pod lib lint lsj-FileManager.podspec

Output:summary: The summary is not meaningful 需要我們完善 summary

-> lsj-FileManager (0.1.0)
    - WARN  | summary: The summary is not meaningful.
    - NOTE  | url: The URL (https://github.com/lishangjing/lsj-FileManager) is not reachable.
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [iOS] xcodebuild:  note: Building targets in dependency order
    - NOTE  | [iOS] xcodebuild:  note: Target dependency graph (3 targets)
    - NOTE  | [iOS] xcodebuild:  note: Signing static framework with --generate-pre-encrypt-hashes (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  /var/folders/cs/08c4rp4s4_l39wwhn08jt3sc0000gn/T/CocoaPods-Lint-20240317-8175-8r0xaa-lsj-FileManager/App.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'App' from project 'App')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'lsj-FileManager' from project 'Pods')

[!] lsj-FileManager did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).
You can use the `--no-clean` option to inspect any issue.

完善 .podspec 文件中的 s.summary 、 s.description

17106686661897.jpg

Input:

pod lib lint lsj-FileManager.podspec

Output:lsj-FileManager passed validation. 校驗(yàn)通過

 -> lsj-FileManager (0.1.0)
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [iOS] xcodebuild:  note: Building targets in dependency order
    - NOTE  | [iOS] xcodebuild:  note: Target dependency graph (3 targets)
    - NOTE  | [iOS] xcodebuild:  note: Signing static framework with --generate-pre-encrypt-hashes (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  /var/folders/cs/08c4rp4s4_l39wwhn08jt3sc0000gn/T/CocoaPods-Lint-20240317-8554-8ralh0-lsj-FileManager/App.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'App' from project 'App')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'lsj-FileManager' from project 'Pods')

lsj-FileManager passed validation.

推送倉庫代碼到 Git

# 進(jìn)如項(xiàng)目根目錄
git init
git add .
git commit -m 'Initial Commit'
git remote add origin https://github.com/lishangjing-spec/lsj-FileManager.git
git branch -M master
git push -u origin master

在 .podspec 文件中我們可以看到

s.source = { :git => 'https://github.com/lishangjing-spec/lsj-FileManager.git', :tag => s.version.to_s }

這里指的是胶惰,我們依賴的下載地址是:
https://github.com/lishangjing-spec/lsj-FileManager.git
同時(shí)傻工,指向的是:s.version tag
.podspecs.version = 0.1.0

17106839678932.jpg

這是默認(rèn)的設(shè)置,我們可以自行更改,也可以遵循這個(gè)規(guī)則

遵循規(guī)則中捆,給我們最新的commit打上tag鸯匹,讓倉庫能引用到我們的代碼

Input:

git tag 0.1.0
git push origin 0.1.0

Output:

Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:lishangjing-spec/lsj-FileManager.git
 * [new tag]         0.1.0 -> 0.1.0

推送項(xiàng)目到 Cocoapods

Input:

pod trunk push lsj-FileManager.podspec

Output:

Updating spec repo `trunk`
Validating podspec
 -> lsj-FileManager
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [iOS] xcodebuild:  note: Building targets in dependency order
    - NOTE  | [iOS] xcodebuild:  note: Target dependency graph (3 targets)
    - NOTE  | [iOS] xcodebuild:  note: Signing static framework with --generate-pre-encrypt-hashes (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  /var/folders/cs/08c4rp4s4_l39wwhn08jt3sc0000gn/T/CocoaPods-Lint-20240317-16091-pb1xlo-lsj-FileManager/App.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'App' from project 'App')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'lsj-FileManager' from project 'Pods')

Updating spec repo `trunk`

--------------------------------------------------------------------------------
 ??  Congrats

 ??  lsj-FileManager (0.1.0) successfully published
 ??  March 17th, 08:27
 ??  https://cocoapods.org/pods/lsj-FileManager
 ??  Tell your friends!

上傳完成

[F&A]

[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

首次上傳或過久沒上傳,需要重新注冊(cè)

Input:

# 接受 Cocoapods 的郵箱泄伪,以及你的名稱(例如:帥哥)
pod trunk register 'xxx@qq.com' 'Name'

Output:進(jìn)入郵箱殴蓬,找到并打開驗(yàn)證鏈接

[!] Please verify the session by clicking the link in the verification email that has been sent to xxx@qq.com

Input:

pod trunk push XXXXX.podspec

.podspec 文件的屬性介紹

s.name:名稱
s.version:版本號(hào)
s.summary:總結(jié)
s.description:描述
s.homepage:倉庫主頁(作用于用戶訪問倉庫首頁)
s.license:開源協(xié)議
s.author:作者
s.source:用戶pod時(shí),依賴?yán)〉牡刂?br> s.ios.deployment_target:依賴支持的版本號(hào)
s.source_files:項(xiàng)目文件路徑
s.resource_bundles:項(xiàng)目資源文件路徑
s.dependency:項(xiàng)目綁定的其他三方依賴
s.frameworks:項(xiàng)目綁定的系統(tǒng) Framework

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末蟋滴,一起剝皮案震驚了整個(gè)濱河市染厅,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌津函,老刑警劉巖肖粮,帶你破解...
    沈念sama閱讀 222,590評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異尔苦,居然都是意外死亡涩馆,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門允坚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來魂那,“玉大人,你說我怎么就攤上這事屋讶”埃” “怎么了?”我有些...
    開封第一講書人閱讀 169,301評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵皿渗,是天一觀的道長(zhǎng)斩芭。 經(jīng)常有香客問我,道長(zhǎng)乐疆,這世上最難降的妖魔是什么划乖? 我笑而不...
    開封第一講書人閱讀 60,078評(píng)論 1 300
  • 正文 為了忘掉前任,我火速辦了婚禮挤土,結(jié)果婚禮上琴庵,老公的妹妹穿的比我還像新娘。我一直安慰自己仰美,他們只是感情好迷殿,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,082評(píng)論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著咖杂,像睡著了一般庆寺。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上诉字,一...
    開封第一講書人閱讀 52,682評(píng)論 1 312
  • 那天懦尝,我揣著相機(jī)與錄音知纷,去河邊找鬼。 笑死陵霉,一個(gè)胖子當(dāng)著我的面吹牛琅轧,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播踊挠,決...
    沈念sama閱讀 41,155評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼乍桂,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了止毕?” 一聲冷哼從身側(cè)響起模蜡,我...
    開封第一講書人閱讀 40,098評(píng)論 0 277
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎扁凛,沒想到半個(gè)月后忍疾,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,638評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡谨朝,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,701評(píng)論 3 342
  • 正文 我和宋清朗相戀三年卤妒,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片字币。...
    茶點(diǎn)故事閱讀 40,852評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡则披,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出洗出,到底是詐尸還是另有隱情士复,我是刑警寧澤,帶...
    沈念sama閱讀 36,520評(píng)論 5 351
  • 正文 年R本政府宣布翩活,位于F島的核電站阱洪,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏菠镇。R本人自食惡果不足惜冗荸,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,181評(píng)論 3 335
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望利耍。 院中可真熱鬧蚌本,春花似錦、人聲如沸隘梨。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽轴猎。三九已至席楚,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間税稼,已是汗流浹背烦秩。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評(píng)論 1 274
  • 我被黑心中介騙來泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留郎仆,地道東北人只祠。 一個(gè)月前我還...
    沈念sama閱讀 49,279評(píng)論 3 379
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像扰肌,于是被迫代替她去往敵國(guó)和親抛寝。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,851評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容