iOS podspec文件添加,支持pod

瞎扯??

小菜雞一直打算上傳下自己寫的一些小demo,上傳過程中遇到了一些小問題再加上自己懶這個打算就擱淺了 ̄□ ̄||??。剛好最近有時間,為了能睡的更香就把之前的坑填下。把關于文件上傳github,添加podspec的過程記錄下。如果有不對的地方歡迎大家指正,一起學習一塊進步。

1.github創建私有倉庫


創建倉庫

2.把本地文件添加到github的倉庫里(已經上傳的跳到下一步)

cd 進入要上傳的文件夾

git init //成功之后你會發現項目里多了一個隱藏文件夾.git

git add . //把所有文件添加到倉庫

git commit -m “提交內容注釋”

git remote add origin?git@github.com:wangxuewen/WXWCategory.git?//關聯github倉庫地址

git push -u origin master //上傳本地代碼

注意:要是第一次上傳項目的話push之前要先git pull 一下。

通常git pull 默認在master分支,

執行命令:git pull origin master?

如果報錯:

fatal: refusing to merge unrelated histories (原因是遠程的倉庫和本地的不一樣)

執行git pull origin master --allow-unrelated-histories

3.創建項目的podspec文件

pod spec create WXWCategory?

這時候本地就生成一個iOS_Category.podspec文件

使用編輯器打開新生成的podspec文件,

Pod::Spec.new do |s|

s.name = "WXWCategory" #和文件名保持一致

s.version = "0.1.0" #新版本一般都是0.1.0(我也不知道為啥,猜的)

s.summary = "基礎數據類型的分類"

s.description = "基礎數據類型分類,方便使用" #description 要比summary長一些,不然會有警告,這個無所謂的,不想寫就不寫了

s.homepage = "https://github.com/wangxuewen/WXWCategory.git

s.license = { :type => "MIT", :file => "LICENSE" }

s.author = { "591807572@qq.com" => "591807572@qq.com" }

s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/wangxuewen/WXWCategory.git", :tag => "0#{s.version}" }

s.source_files = "WWXCategory", "WWXCategory/**/*.{h,m}"

s.exclude_files = "Classes/Exclude"

4.驗證podspec文件

?pod lib lint --allow-warnings # --allow-warnings 屏蔽警告

如果出現Error但是提示信息不足,可以添加--verbose?以獲取更多錯誤信息

?pod lib lint --verbose

5.打tag 上傳podspec

git tag -m"first tag WXWCategory" "0.1.0"

git push --tags

6.把podspec文件推送到CocoaPod官方庫

?pod trunk push WXWCategory.podspec


7.用pod 搜索

pod search WXWCategory

新上傳的庫可能會搜不到,先pod setup更新我們本地的CocoaPods space庫,如果還是不可以,清理下搜索緩存

rm ~/Library/Caches/CocoaPods/search_index.json

再搜索就可以了。 (http://blog.sina.com.cn/s/blog_14d7dd6710102wc1w.html

出現的問題

error1:

- WARN | description: The description is shorter than the summary. - WARN | license: Unable to find a license file - ERROR | xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information. - NOTE | [OSX] xcodebuild: CocoapodTest/CocoapodTest/AppDelegate.h:9:9: fatal error: 'UIKit/UIKit.h' file not found - NOTE | [OSX] xcodebuild: CocoapodTest/CocoapodTest/APWheelSurfViewController.h:9:9: fatal error: 'UIKit/UIKit.h' file not found - NOTE | [iOS] xcodebuild: CocoapodTest/CocoapodTest/APWheelSurfViewController.m:12:9: fatal error: 'YYModel/YYModel.h' file not found - ERROR | [tvOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.

解決方案:私有庫的三方依賴用這種方式

? s.dependency "MJRefresh", "~> 3.1.12"

error2:

Specs satisfying the `YYModel (~> 1.0.4)` dependency were found, but they required a higher minimum deployment target.) during validation.

解決方案:Podfile 文件 中 platform:ios, ‘9.0’ 后邊的 9.0 是平臺版本號 ,一定要加上

error3:

-> WXWCategory (0.1.0) - ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.[!] The spec did not pass validation, due to 1 error.[!] Unable to read the license file `FILE_LICENSE` for the spec `WXWCategory (0.1.0)`[!] Unable to read the license file `FILE_LICENSE` for the spec `WXWCategory (0.1.0)`

這個錯誤也是使用指令pod trunk push WXWCategory.podspec 檢查文件是否合法時發生的;

這個是在指定共享的類庫時, 文件路徑不對, 也就是設置s.source_files 字段時, 發生了錯誤, 這里的路徑是相對于WXWCategory.podspec文件的, 如果是與WXWCategory.podspec同級的文件夾, 直接寫文件夾名稱即可, 如:

s.source_files = "WXWCategory"

如果有多級目錄, 一定要逐級添加. 這里也可以這么寫:

s.source_files = "WXWCategory/*.{h,m}" //或者s.source_files = "WXWCategory/*"

error4:

Unable to interpret the specified path `WXWCategory.podspec` as a podspec (Pod::DSLError).

podspec文件中有中文標點,仔細檢查下??

error5:

[!] Unable to read the license file `FILE_LICENSE` for the spec `WXWLuckView (0.0.1)`

本來默認生成的是: s.license = { :type => "MIT", :file => "FILE_LICENSE" }, 看錯誤的意思是找不到FILE_LICENSE這個文件,改成s.license = { :type => "MIT", :file => "LICENSE" }就好了,這個錯誤要多試下,看其他文章有不通的解決方法,可能是和環境有關系。

error6:

[!] Unable to accept duplicate entry for: WXWLuckView (0.0.1)

字面意思是不能接受重復輸入,修改podspec文件中s.version與tag保持一致即可。

error7:

[!] {"name"=>["is already taken"]}

已經有重名的私有庫

error8:

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

郵箱重新驗證下即可:

1.pod trunk register 你的郵箱

2.打開郵箱驗證重新執行

3.pod trunk push podspec (提交podspec文件)

error9:

[!] Error installing libwebp

[!] /usr/bin/git clone https://chromium.googlesource.com/webm/libwebp /var/folders/gr/3pwv50y90db54sygb37d32jh0000gn/T/d20190923-34418-1n7wqfk --template= --single-branch --depth 1 --branch v1.0.2

Cloning into '/var/folders/gr/3pwv50y90db54sygb37d32jh0000gn/T/d20190923-34418-1n7wqfk'...

fatal: unable to access 'https://chromium.googlesource.com/webm/libwebp/': Failed to connect to chromium.googlesource.com port 443: Operation timed out

更換libwebp源文件的下載鏈接

a. Finder -> 前往文件夾 (??G)? ?? ~/.cocoapods/repos/master/Specs/1/9/2/libwebp

b.把https://chromium.googlesource.com/webm/libwebp?替換為?https://github.com/webmproject/libwebp.git?并保存

上傳的demo(WXWCategory)

c.重新pod install

error10:

$ Specs satisfying the `QMUIKit (~> 4.1.3)` dependency were found, but they required a higher minimum deployment target

問題原因:找到了依賴項,但需要更高的最低部署目標,調整 podfile文件中platform :ios,'8.0'?更新到高版本或者把目標依賴"QMUIKit"的版本調低

error11:

GET https://gems.ruby-china.org/specs.4.8.gz

404 Not Found

ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

https://gems.ruby-china.org/ 訪問不了

域名改為

https://gems.ruby-china.com/

具體操作如下圖:


error12:

git@gitee.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

問題原因:本地沒有生成ssh公鑰或者生成的ssh有問題。

解決思路:
1.當你沒有ssh公鑰的時候,在Terminal中執行(其中gitee_id_rsa為你要生成的ssh公鑰的文件名稱,xxxx@qq.com為你的郵箱)

ssh-keygen -t rsa -C 'xxxx@qq.com' -f ~/.ssh/gitee_id_rsa

2. 執行ssh -v git@github.com,過程中輸入yes

ssh -v git@github.com


3. 執行?ssh-agent -s

ssh-agent -s

4.執行 ssh-add ~/.ssh/gitee_id_rsa

ssh-add ~/.ssh/gitee_id_rsa

如果出現問題 "could not open a connection to your authentication agent",則執行?eval `ssh-agent -s` 之后再執行?ssh-add ~/.ssh/gitee_id_rsa

5.執行 ssh -T git@gitee.com,驗證是否配置成功。出現下面結果則恭喜你啦

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 227,533評論 6 531
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,055評論 3 414
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,365評論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,561評論 1 307
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,346評論 6 404
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 54,889評論 1 321
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 42,978評論 3 439
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,118評論 0 286
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,637評論 1 333
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,558評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,739評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,246評論 5 355
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 43,980評論 3 346
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,362評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,619評論 1 280
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,347評論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,702評論 2 370

推薦閱讀更多精彩內容