本文源自本人的學(xué)習(xí)記錄整理與理解钠惩,其中參考閱讀了部分優(yōu)秀的博客和書(shū)籍貌亭,盡量以通俗簡(jiǎn)單的語(yǔ)句轉(zhuǎn)述钳宪。引用到的地方如有遺漏或未能一一列舉原文出處還望見(jiàn)諒與指出,另文章內(nèi)容如有不妥之處還望指教隐砸,萬(wàn)分感謝之碗。
XXX did not pass valibation,due to 1 error
這種情況是組件驗(yàn)證常見(jiàn)錯(cuò)誤,一般會(huì)有 - ERROR 提示季希;根據(jù)錯(cuò)誤提示修改即可褪那;但有時(shí)會(huì)遇到?jīng)]有任何- ERROR
的情況,這時(shí)首先在驗(yàn)證選項(xiàng)中添加 --verbose
在次驗(yàn)證胖眷; 可以搜索 fail 和 error看看有沒(méi)有信息武通;已然沒(méi)有時(shí)建議使用遠(yuǎn)程驗(yàn)證的方式在此驗(yàn)證;這時(shí)可能就能拿到錯(cuò)誤信息了珊搀,修改直至驗(yàn)證通過(guò)就可以提交podspec文件
注意:遠(yuǎn)程驗(yàn)證必需先提交代碼到遠(yuǎn)程倉(cāng)庫(kù)的
[!] The XXPhotoKit.podspec
specification does not validate.
1.本地版本和遠(yuǎn)程不同步造成
2.或者是項(xiàng)目支持最低版本不一致造成
3.是本地索引庫(kù)的問(wèn)題冶忱,可以重新建一個(gè)索引庫(kù)提交試試;前提是spec文件驗(yàn)證沒(méi)有問(wèn)題
主工程集成報(bào)錯(cuò)
[!] Unable to find a specification for `ZLPhotoBrowser` depended upon by `XXPhotoKit`
You have either:
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
主工程集成時(shí)需要添加一下source到podfile文件:
source 'https://github.com/CocoaPods/Specs.git'
索引庫(kù)報(bào)錯(cuò)
[!] Unable to add a source with url https://github.com/CocoaPods/Specs.git
named cocoapods
.
You can try adding it manually in /Users/mac/.cocoapods/repos
or via pod repo add
.
[!無(wú)法添加url ' https://github.com/CocoaPods/Specs.git ' named ' cocoapods '的源文件境析。
你可以嘗試在' /Users/mac/中手動(dòng)添加囚枪。cocoapods/repos '或通過(guò)' pod repo add '。
Unable to find a specification for XXXXX
[!] Unable to find a specification for `PTBLogInModel`
You have either:
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
解決方法:
- 更新本地索引庫(kù):pod repo update
pod install 報(bào)錯(cuò) An unexpected version directory
![[!] An unexpected version directory `Classes.png](https://upload-images.jianshu.io/upload_images/4068785-9f40cb97a5427b9f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
這個(gè)錯(cuò)誤劳淆,請(qǐng)查看:
podspec 是否未上傳到服務(wù)器
Podfile的source地址是否是Spec Repo的地址链沼,而不是具體某一個(gè)Pod的地址。
請(qǐng)注意:只需要配置索引庫(kù)的源即可
platform :ios, '9.0'
source 'https://gitee.com/xxx/PTBSpecs.git'
target 'MainUIKit' do
pod 'XXXUIKit'
end
沒(méi)有分支權(quán)限
[!] /usr/bin/git -C /Users/mac/.cocoapods/repos/PTBPods push origin HEAD
remote: GitLab: You are not allowed to push code to protected branches on this project.
To code.aliyun.com:pintuibao-ios/PTBPods.git
! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to 'git@code.aliyun.com:pintuibao-ios/PTBPods.git'
解決:開(kāi)放權(quán)限即可沛鸵,比如去除可保護(hù)
[!] The 'Pods-PXXXKit_Example' target has transitive dependencies that include statically linked binaries:
私有庫(kù)內(nèi)部用到第三方庫(kù)時(shí)需要在Podfile注掉 use_frameworks!
[iOS] unknown: Encountered an unknown error The Pods-App xxx
- ERROR | [iOS] unknown: Encountered an unknown error
(The 'Pods-App' target has transitive dependencies that include statically linked binaries:
(/private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-70817-ltom55-PTBPushKit/Pods/JCore/libjcore-noidfa-ios-2.1.4.a
and /private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-70817-ltom55-PTBPushKit/Pods/JPush/libjpush-noidfa-ios-3.2.4.a))
during validation.
--verbose 顯示檢查編譯的詳細(xì)信息
--allow-warnings 驗(yàn)證時(shí)允許有警告
pod lib lint --verbose --use-libraries --allow-warnings
pod lib lint xxxKit.podspec --verbose --use-libraries --allow-warnings --no-clean
[iOS] xcodebuild: Returned an unsuccessful exit code.
解決:文件內(nèi)的引用地址要使用這樣的形式 :#import <組件名/文件名.h>
- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include statically linked binaries: (/private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-71677-zezx08-PushKit/Pods/JCore/libjcore-noidfa-ios-2.1.4.a and /private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-71677-zezx08-PushKit/Pods/JPush/libjpush-noidfa-ios-3.2.4.a)) during validation.
依賴第三方極光推送庫(kù)報(bào)錯(cuò)
podspec文件中依賴了靜態(tài)庫(kù)造成的驗(yàn)證不通過(guò)括勺,想要驗(yàn)證通過(guò)可以通過(guò)添加參數(shù)--use-libraries讓驗(yàn)證通過(guò),這樣操作并不影響pod使用
pod lib lint xxx.podspec --verbose --use-libraries --allow-warnings
- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include statically linked binaries: (/private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-80124-66n1vl-XXXPushKit/Pods/JCore/libjcore-noidfa-ios-2.1.4.a and/private/var/folders/3c/3_qr291s5qdgjw93530cr7_w0000gn/T/CocoaPods-Lint-20200617-80124-66n1vl-XXXPushKit/Pods/JPush/libjpush-noidfa-ios-3.2.4.a)) during validation.
這個(gè)錯(cuò)誤的原因是第三方的SDK編譯導(dǎo)致的報(bào)錯(cuò)缆八;需要設(shè)定arm64 x86_64架構(gòu),所以在podspec添加如下代碼即可
s.xcconfig = { 'VALID_ARCHS' => 'arm64 x86_64', }
私有庫(kù)添加友盟統(tǒng)計(jì)~鏈接報(bào)錯(cuò)
duplicate symbol '_OBJC_IVAR_$_UMComCountEvent._key' in:
/Users/mac/Desktop/PTBTest/BasisProject/XSDAnalyticsKit/Example/Pods/UMCAnalytics/UMAnalytics.framework/UMAnalytics(UMComCountEvent.o)
ld: 164 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
類似問(wèn)題可以從第三方升級(jí)的的SDK文檔中尋找線索疾捍,一般第三方SDK升級(jí)奈辰,如果沒(méi)有更新且第三方SDK名字沒(méi)變的情況下很可能會(huì)出現(xiàn)多個(gè)重復(fù)文件;這里出現(xiàn)的就是友盟統(tǒng)計(jì)SDK升級(jí)導(dǎo)致
- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include statically linked binaries: (XSDAnalyticsKit/Pods/UMCCommon/UMCommon.framework XAnalyticsKit/Pods/UMCCommonLog/UMCommonLog/UMCommonLog.fram)) during validation.
App的目標(biāo)有傳遞依賴乱豆,包括靜態(tài)鏈接的二進(jìn)制文件奖恰,需要添加驗(yàn)證條件--use-libraries
將命令:pod lib lint --allow-warnings
改為:pod lib lint --use-libraries --allow-warnings
第二種情況:
若是自己封裝的庫(kù),依賴的第三方里面包含了靜態(tài)庫(kù)宛裕,直接修改podspec瑟啃,添加:
s.static_framework = true
`[!] CocoaPods could not find compatible versions for pod "PTBEncryptKit":
In Podfile:
PTBEncryptKit (from ../
)
Specs satisfying the PTBEncryptKit (from
../)
dependency were found, but they required a higher minimum deployment target.`
此類問(wèn)題一般是有platform :ios, '9.0'版本不一致導(dǎo)致的,可以檢查版本號(hào)
- ERROR | name: The name of the spec should match the name of the file.
spec文件的名稱有誤揩尸,請(qǐng)檢查xxxx.podspec文件名是否正確
`- ERROR | [iOS] [XXStoreKit/XXStoreParser] xcodebuild: Returned an unsuccessful exit code.
- NOTE | [XXStoreKit/PTBStoreParser] xcodebuild: /Users/mac/Desktop/XX_XSD_Project/XXStoreKit/XXStoreKit/Classes/XXStoreParser/XXStoreParser.m:10:9: fatal error: 'XXKeyChainStore.h' file not found`
錯(cuò)誤: PTBKeyChainStore沒(méi)有找到 .h 文件
iOS [!] The repo
XXPodsat
../../../.cocoapods/repos/XXPodsis not clean
先移除本地索引庫(kù)
repo remove XXPods
再?gòu)倪h(yuǎn)程添加會(huì)來(lái)
repo add XXPods 索引庫(kù)地址
error: include of non-modular header inside framework module 'XXXStoreKit.XXDB':
框架模塊XXXStoreKit.XXDB中包含非模塊化頭文件蛹屿,即在XXDB中包含了非當(dāng)前模塊的頭文件
解決辦法就是:添加依賴
s.dependency 'XXXStoreKit/XXXFMDB/FMDB'
- ERROR | Release- error: include of non-modular header inside framework module 'XXXLoadingKit.MBProgressHUD_XXXExtend': [-Werror,-Wnon-modular-include-in-framework-module]
查看私有庫(kù).h文件中引入方式是否是"MBProgressHUD.h", 如果是先改成 < MBProgressHUD/MBProgressHUD.h>
前提是:可以正常運(yùn)行項(xiàng)目; 驗(yàn)證時(shí)使用:pod lib lint --allow-warnings
解決添加:--use-libraries
pod lib lint --allow-warnings --use-libraries
Could not build module 'XXXPushKit'
一般類似問(wèn)題是因?yàn)樗接袔?kù)引用第三方SDK時(shí)疲酌,引用方式不正確導(dǎo)致蜡峰;如果可以最好在.m文件引入,或者.h使用<>的方式
Include of non-modular header inside framework module ‘xxx’
描述:
在SDK開(kāi)發(fā)過(guò)程中朗恳,我們自己的framework庫(kù)中的一個(gè).h文件引用了pod庫(kù)中的類
這時(shí)候以源碼的形式build是沒(méi)有問(wèn)題的,但是當(dāng)build出靜態(tài)庫(kù)后载绿,添加到其他項(xiàng)目中使用時(shí)粥诫,就報(bào) Include of non-modular header inside framework module xxxx錯(cuò)誤。
為什么會(huì)這樣呢?
因?yàn)閄code在默認(rèn)情況下是不允許在framework中的頭文件引入一個(gè)不屬于任何Module的頭文件崭庸。
普通解決:將Build Settings中的Allow Non-modular Includes In Framework Modules設(shè)為YES
方式二:
但是私有庫(kù)別人集成可能就會(huì)有問(wèn)題怀浆,此時(shí)建議添加以下配置,本質(zhì)上和第一種方式類似怕享;
s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }
詳細(xì)了解可以查看這篇文章
- ERROR | [XXXPushKit/XXXJPUSHService] file patterns: The
source_filespattern did not match any file.
頻繁操作私有庫(kù)podspec文件后执赡,語(yǔ)法都沒(méi)有問(wèn)題;項(xiàng)目也可以正常運(yùn)行函筋;但就是在本地校驗(yàn)時(shí)失斏澈稀;這時(shí)可能就是緩存春的問(wèn)題跌帐,有時(shí)pod install 后不一定就可以首懈,看起來(lái)沒(méi)問(wèn)題;事實(shí)上多次校驗(yàn)都無(wú)法通過(guò)谨敛。這時(shí)候需要清理下cocoapods緩存究履,清理工程xcode緩存是無(wú)效的;
直接前往:~/資源庫(kù)/Caches/CocoaPods/Pods/
/Users/mac/Library/Caches/CocoaPods/Pods/External/XXXPushKit/349f5495df6442f748c403e90110e181-5ff3a
刪除掉XXXPushKit文件脸狸,重新走校驗(yàn)流程最仑;如果還是不行,可以直接嘗試把私有庫(kù)的XXXPushKit文件拷貝到349f5495df6442f748c403e90110e181-5ff3a中,即可通過(guò)校驗(yàn)
- ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for AliPlayerSDK_iOS depended upon by XXXX
項(xiàng)目模塊化時(shí)泥彤,我們制作的私有庫(kù)免不了依賴其他私有庫(kù)和CocoaPods的公有庫(kù)紊搪。在產(chǎn)品更新迭代制作新版本的私有庫(kù)后,準(zhǔn)備提交私有庫(kù)前的驗(yàn)證環(huán)境如果沒(méi)有給驗(yàn)證私有庫(kù)的命令知道地址一般都會(huì)報(bào)如下錯(cuò)誤全景。但是如果項(xiàng)目中如果只有公共庫(kù)應(yīng)該不會(huì)報(bào)錯(cuò)耀石,因?yàn)轵?yàn)證和提交的時(shí)候默認(rèn)回去官方specs庫(kù)校驗(yàn),目前寫(xiě)的庫(kù)還沒(méi)有只依賴公有庫(kù)的爸黄。
校驗(yàn)podspec文件時(shí)會(huì)到遠(yuǎn)程podspec庫(kù)查找相關(guān)依賴滞伟,默認(rèn)只會(huì)到官方specs庫(kù)校驗(yàn),此時(shí)需要指定遠(yuǎn)程specs庫(kù)去校驗(yàn)炕贵。
podspec文件在寫(xiě)依賴的時(shí)候也無(wú)法在對(duì)應(yīng)的庫(kù)后面添加源地址梆奈。但是我們可以在驗(yàn)證和提交的時(shí)候加上--sources參數(shù)。注意--sources后面也需要加上官方源称开,不然會(huì)報(bào)找不到公開(kāi)的第三方庫(kù)亩钟。
pod spec lint --verbose --use-libraries --allow-warnings --sources='git@私有庫(kù)地址.git,https://github.com/CocoaPods/Specs.git'