iOS組件化 Cocoapods管理自己的庫(kù)

github 創(chuàng)建倉(cāng)庫(kù)

new 一個(gè) repository

創(chuàng)建倉(cāng)庫(kù)

clone 到本地 并初始化工程

創(chuàng)建.podspec文件

$pod spec create 工程名
創(chuàng)建.podspec文件

文本編輯打開.podspec文件

  Pod::Spec.new do |s|

  s.name         = "RJMyPod"
  s.version      = "0.0.1"
  s.summary      = "A iOS Fast integration of custom classifications, macro definitions and tool classes"
  s.homepage     = "https://github.com/Jack424/RJMyPod.git"
  s.license      = "MIT"
  s.author       = { "Jack_Gu" => "gu_ruijie@163.com" }
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/Jack424/RJMyPod.git", :tag => s.version}
  s.source_files = "RJMyPod/RJMyPod/MyPod/*.{h,m}"
  s.requires_arc = true
 s.resources    = "RJCategoryTool/RJCategoryTool/RJCategoryTool/Resource/*.{png,xib,nib,bundle,json}"
end
  s.dependency 'Masonry'
  
  # s.resources    = 'PhotoBrowser/resource/*.{png,xib,nib,bundle}'
  # s.frameworks   = 'UIKit','Photos','PhotosUI'
  # s.dependency 'UMengUShare/Social/ReducedWeChat', '~> 6.4.8.2'
end
  s.name          :工程名
  s.version       :版本號(hào)
  s.summary       :簡(jiǎn)介概述
  s.homepage      :github項(xiàng)目網(wǎng)頁(yè) 
  s.license       :授權(quán)許可文件 
  s.author        :代碼作者
  s.platform      :支持最低的版本號(hào)
  s.source        :git代碼下載地址
  s.source_files  :胎源!重要 唯欣! 你要傳到cocoapods的文件內(nèi)容  
  s.resources     :資源文件余蟹,沒有可忽略
  s.requires_arc  :是否是ARC 

注意:s.source_files 下層級(jí)目錄一定是podspec所在層級(jí)的文件名開始到你要上傳的文件目錄為止 *.{h,m} 表示匹配所有以.h和.m結(jié)尾的文件 ** 表示匹配所有子目錄 若所上傳文件夾有子級(jí)文件則在文件名后追加 **/*.{h,m}

解決[-Werror,-Wnon-modular-include-in-framework-module]錯(cuò)誤, .h文件中引用第三方庫(kù) #import <Masonry/Masonry.h>,使用尖括號(hào)引用

上傳過程中遇到問題就細(xì)心檢查一下

$ git add --all
$ git commit -m "操作內(nèi)容"
$ git tag "0.0.1"
$ git push --tags
$ git push origin master

驗(yàn)證上傳是否合法

$ pod spec lint --allow-warnings
 -> RJMyPod (0.0.1)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')

Analyzed 1 podspec.

RJMyPod.podspec passed validation.

出現(xiàn)成功提示后就trunk上傳扁藕,如果沒有沒有注冊(cè)過需要首次注冊(cè)

$ pod trunk register 郵箱 '用戶名' --description='描述一下下'

郵箱及用戶名以你GitHub的為準(zhǔn)
提交指令后需要去郵箱驗(yàn)證,點(diǎn)擊或復(fù)制郵箱郵件內(nèi)的鏈接會(huì)顯示

郵件內(nèi)容

自我驗(yàn)證

$ pod trunk me
- Name:     Jack424
  - Email:    gu_ruijie@163.com
  - Since:    September 18th, 2017 21:46
  - Pods:
    - GRJKit
    - GRJMITKit
    - RJCategoryTool
  - Sessions:
    - September 18th, 2017 21:46 - January 25th, 2018 01:13. IP: 120.236.169.38
    Description: macbook pro
    - February 14th, 20:57       -         June 23rd, 05:36. IP: 27.115.4.10   
    Description: 描述一下下
  • 報(bào)錯(cuò)及解決
$ pod trunk me
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

$ pod trunk register 'gu_ruijie@163.com' 'Jack424' --description='mac pro'
// 然后去郵箱操作一下即可
/*
Please confirm your CocoaPods session by clicking the following link:

    https://trunk.cocoapods.org/sessions/verify/**************

If you did not request this you do not need to take any further action.
*/

提交

$ pod trunk push --allow-warnings
上傳pod成功

使用一下

  pod 'RJMyPod'

$ pod install
試一試

如果報(bào)錯(cuò):- ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

$ sudo gem install -n /usr/local/bin cocoapods

Password:
Fetching: cocoapods-core-1.7.1.gem (100%)
Successfully installed cocoapods-core-1.7.1
Fetching: cocoapods-deintegrate-1.0.4.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.4
Fetching: xcodeproj-1.9.0.gem (100%)
Successfully installed xcodeproj-1.9.0
Fetching: fourflusher-2.3.0.gem (100%)
Successfully installed fourflusher-2.3.0
... ...

ZLPhotoBrowser 使用 SDWebImage 報(bào)錯(cuò)
打印錯(cuò)誤信息

pod spec lint RJCategoryTool.podspec --verbose 
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE  | xcodebuild:  note: Using new build system
- NOTE  | [iOS] xcodebuild:  note: Planning build
- NOTE  | [iOS] xcodebuild:  note: Constructing build description
- ERROR | [iOS] xcodebuild:  ZLPhotoBrowser/ZLPhotoBrowser/PhotoBrowser/ZLBigImageCell.m:504:77: error: use of undeclared identifier 'SDWebImageProgressiveDownload'; did you mean 'SDWebImageProgressiveLoad'?
- NOTE  | [iOS] xcodebuild:  SDWebImage/SDWebImage/Core/SDWebImageDefine.h:69:5: note: 'SDWebImageProgressiveLoad' declared here

[!] The spec did not pass validation, due to 2 errors.

ZLPhotoBrowser更新日志
3.0.3: 依賴庫(kù)SDWebImage升級(jí)為5.0.2以上

● 3.0.6: 添加選中圖片顯示index功能; 新增(及修改)部分顏色api摹察,方便修改框架內(nèi)部顏色; 修改框架默認(rèn)風(fēng)格為微信的風(fēng)格; 壓縮圖片資源;
● 3.0.5: 預(yù)覽快速選擇界面文字顏色支持自定義; 編輯界面按鈕增大; 解決錄制視頻超過10s沒有聲音的bug;
● 3.0.4: 添加視頻選擇最大最小個(gè)數(shù)限制; 解決網(wǎng)絡(luò)gif圖片無法播放的bug; fix已知bug;
● 3.0.3: 依賴庫(kù)SDWebImage升級(jí)為5.0.2以上; 解決圖片瀏覽器關(guān)閉時(shí)取消所有sd圖片請(qǐng)求的bug; 支持直接調(diào)用相機(jī);
● 3.0.0: 壓縮bundle內(nèi)圖片; 支持直接選擇iCloud照片豁生,并添加解析圖片超時(shí)時(shí)間屬性;
● 3.0.0: 支持carthage; 去除GPUImage濾鏡;
● 2.7.8: 添加iCloud圖片加載進(jìn)度條,支持iCloud視頻播放;
● 2.7.6: 預(yù)覽大圖界面支持precent情況下的下拉返回;
● 2.7.5: 編輯圖片支持自定義工具類型; bug fixed;
● 2.7.4: 橫滑大圖界面添加下拉返回; 不允許錄制視頻時(shí)候不請(qǐng)求麥克風(fēng)權(quán)限;
● 2.7.1: 支持自定義導(dǎo)航返回按鈕圖片;
● 2.7.0: 圖片資源加上前綴咖楣,解決9.0無法選擇圖片問題; 
● 2.6.9: 重構(gòu)編輯圖片功能,添加濾鏡;
● 2.6.7: 優(yōu)化視頻編輯界面芦昔,極大減少進(jìn)入時(shí)的等待時(shí)間;
● 2.6.6: Fix #216; 新增隱藏裁剪圖片界面比例工具條功能;
● 2.6.5: 新增隱藏"已隱藏"照片及相冊(cè)的功能; Fix #221, 優(yōu)化預(yù)覽網(wǎng)絡(luò)圖片/視頻時(shí)根據(jù)url后綴判斷的類型方式;



報(bào)錯(cuò)

[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

$ pod update
Update all pods
Updating local specs repositories
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

$ pod repo update master --verbose
Updating spec repo `master`
  $ /usr/bin/git -C /Users/jintian/.cocoapods/repos/master fetch origin --progress
  remote: Enumerating objects: 12756, done.        
  remote: Counting objects: 100% (12756/12756), done.        
  remote: Compressing objects: 100% (440/440), done.        
  remote: Total 33049 (delta 12458), reused 12299 (delta 12299), pack-reused 20293        
  Receiving objects: 100% (33049/33049), 3.68 MiB | 85.00 KiB/s, done.
  Resolving deltas: 100% (22711/22711), completed with 3716 local objects.
  From https://github.com/CocoaPods/Specs
     279b00360ea..4826f4cad15  master     -> origin/master
  $ /usr/bin/git -C /Users/jintian/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/jintian/.cocoapods/repos/master reset --hard origin/master
  Checking out files: 100% (3441/3441), done.
  HEAD is now at 4826f4cad15 [Add] QBRouter 0.0.5

$ pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking 4.0.1 (was 3.2.1 and source changed to `https://github.com/CocoaPods/Specs.git` from `trunk`)
Installing AlipaySDK-iOS 15.7.4 (was 15.6.8 and source changed to `https://github.com/CocoaPods/Specs.git` from `trunk`)
Installing MBProgressHUD 1.2.0 (was 1.1.0 and source changed to `https://github.com/CocoaPods/Specs.git` from `trunk`)
Installing MJRefresh 3.4.1 (was 3.2.2 and source changed to `https://github.com/CocoaPods/Specs.git` from `trunk`)
Installing WechatOpenSDK 1.8.7.1 (was 1.8.6 and source changed to `https://github.com/CocoaPods/Specs.git` from `trunk`)
Generating Pods project
Integrating client project
Pod installation complete! There are 17 dependencies from the Podfile and 17 total pods installed.

[!] Automatically assigning platform `iOS` with version `10.0` on target `RJCategoryTool` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] CDN: trunk URL couldn't be downloaded:

$ pod search AFNetworking
[!] CDN: trunk Repo update failed - 2 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/a/7/5/AFNetworking/4.0.0/AFNetworking.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/a/7/5/AFNetworking/4.0.1/AFNetworking.podspec.json Response: Couldn't connect to server

$ pod repo remove trunk

- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use--verbosefor more information.

    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    ...
    [!] The spec did not pass validation, due to 1 error.
$ pod spec lint RJCategoryTool.podspec --verbose //打印錯(cuò)誤信息

ERROR | [iOS] unknown: Encountered an unknown error (/usr/bin/xcrun simctl list -j devices

$ pod trunk push  --allow-warnings 
$ pod trunk push  --allow-warnings --use-libraries
Updating spec repo `master`

CocoaPods 1.8.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.8.0

Validating podspec
 -> RJCategoryTool (0.5.5)
    - ERROR | [iOS] unknown: Encountered an unknown error (/usr/bin/xcrun simctl list -j devices

xcrun: error: unable to find utility "simctl", not a developer tool or in PATH
) during validation.

[!] The spec did not pass validation, due to 1 error.
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Password:
$ pod trunk push RJCategoryTool.podspec --allow-warnings --use-libraries
Updating spec repo `master`

CocoaPods 1.8.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.8.0

Validating podspec
 -> RJCategoryTool (0.5.5)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
...

...
Updating spec repo `master`

CocoaPods 1.8.0 is available.
To update use: `sudo gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.8.0


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

 ??  RJCategoryTool (0.5.5) successfully published
 ??  September 27th, 04:59
 ??  https://cocoapods.org/pods/RJCategoryTool
 ??  Tell your friends!
--------------------------------------------------------------------------------

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末诱贿,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子咕缎,更是在濱河造成了極大的恐慌珠十,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,451評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件凭豪,死亡現(xiàn)場(chǎng)離奇詭異焙蹭,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)嫂伞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,172評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門孔厉,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人帖努,你說我怎么就攤上這事撰豺。” “怎么了拼余?”我有些...
    開封第一講書人閱讀 164,782評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵污桦,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我匙监,道長(zhǎng)寡润,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,709評(píng)論 1 294
  • 正文 為了忘掉前任舅柜,我火速辦了婚禮梭纹,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘致份。我一直安慰自己变抽,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,733評(píng)論 6 392
  • 文/花漫 我一把揭開白布氮块。 她就那樣靜靜地躺著绍载,像睡著了一般。 火紅的嫁衣襯著肌膚如雪滔蝉。 梳的紋絲不亂的頭發(fā)上击儡,一...
    開封第一講書人閱讀 51,578評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音蝠引,去河邊找鬼阳谍。 笑死蛀柴,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的矫夯。 我是一名探鬼主播鸽疾,決...
    沈念sama閱讀 40,320評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼训貌!你這毒婦竟也來了制肮?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,241評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤递沪,失蹤者是張志新(化名)和其女友劉穎豺鼻,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體款慨,經(jīng)...
    沈念sama閱讀 45,686評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡儒飒,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,878評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了樱调。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片约素。...
    茶點(diǎn)故事閱讀 39,992評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖笆凌,靈堂內(nèi)的尸體忽然破棺而出圣猎,到底是詐尸還是另有隱情,我是刑警寧澤乞而,帶...
    沈念sama閱讀 35,715評(píng)論 5 346
  • 正文 年R本政府宣布送悔,位于F島的核電站,受9級(jí)特大地震影響爪模,放射性物質(zhì)發(fā)生泄漏欠啤。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,336評(píng)論 3 330
  • 文/蒙蒙 一屋灌、第九天 我趴在偏房一處隱蔽的房頂上張望洁段。 院中可真熱鬧,春花似錦共郭、人聲如沸祠丝。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,912評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)写半。三九已至,卻和暖如春尉咕,著一層夾襖步出監(jiān)牢的瞬間叠蝇,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,040評(píng)論 1 270
  • 我被黑心中介騙來泰國(guó)打工年缎, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留悔捶,地道東北人铃慷。 一個(gè)月前我還...
    沈念sama閱讀 48,173評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像炎功,于是被迫代替她去往敵國(guó)和親枚冗。 傳聞我的和親對(duì)象是個(gè)殘疾皇子缓溅,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,947評(píng)論 2 355