瞎扯??
小菜雞一直打算上傳下自己寫的一些小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?并保存
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/ 訪問不了
域名改為
具體操作如下圖:
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,驗證是否配置成功。出現下面結果則恭喜你啦