iOS 组件化私有库常见问题

iOS 组件化私有库常见问题,第1张

问题一
XXX did not pass valibation,due to 1 error

这种情况是组件验证常见错误,一般有 - ERROR 提示;根据错误提示修改即可;但有时会遇到没有任何- ERROR的情况,这时首先在验证选项中添加 --verbose 在次验证; 可以搜索 fail 和 error看看有没有信息;已然没有时建议使用远程验证的方式在此验证;这时可能就能拿到错误信息了,修改直至验证通过就可以提交podspec文件
注意:远程验证必需先提交代码到远程仓库的

问题二
[!] The XXPhotoKit.podspec specification does not validate.

1.本地版本和远程不同步造成
2.或者是项目支持最低版本不一致造成
3.是本地索引库的问题,可以重新建一个索引库提交试试;前提是spec文件验证没有问题

问题三 主工程集成报错
[!] 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.

主工程集成时需要添加一下source到podfile文件:
source ‘https://github.com/CocoaPods/Specs.git’

问题四 索引库报错
[!] 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.

[!无法添加url ’ https://github.com/CocoaPods/Specs.git ’ named ’ cocoapods ‘的源文件。
你可以尝试在’ /Users/mac/中手动添加。cocoapods/repos ‘或通过’ 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.

解决方法:
更新本地索引库:pod repo update
pod install 报错 An unexpected version directory

问题六


这个错误,请查看:

podspec 是否未上传到服务器
Podfile的source地址是否是Spec Repo的地址,而不是具体某一个Pod的地址。

请注意:只需要配置索引库的源即可

platform :ios, '9.0'

source 'https://gitee.com/xxx/PTBSpecs.git'

target 'MainUIKit' do

pod 'XXXUIKit'

end
问题七 没有分支权限
[!] /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 '[email protected]:pintuibao-ios/PTBPods.git'

解决:开放权限即可,比如去除可保护

问题八
[!] The 'Pods-PXXXKit_Example' target has transitive dependencies that include statically linked binaries:

私有库内部用到第三方库时需要在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 显示检查编译的详细信息
–allow-warnings 验证时允许有警告

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.

解决:文件内的引用地址要使用这样的形式 :#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.
问题十一 依赖第三方极光推送库报错

podspec文件中依赖了静态库造成的验证不通过,想要验证通过可以通过添加参数–use-libraries让验证通过,这样 *** 作并不影响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.

这个错误的原因是第三方的SDK编译导致的报错;需要设定arm64 x86_64架构,所以在podspec添加如下代码即可

s.xcconfig = { ‘VALID_ARCHS’ => ‘arm64 x86_64’, }

问题十二 私有库添加友盟统计~链接报错
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)

类似问题可以从第三方升级的的SDK文档中寻找线索,一般第三方SDK升级,如果没有更新且第三方SDK名字没变的情况下很可能会出现多个重复文件;这里出现的就是友盟统计SDK升级导致

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的目标有传递依赖,包括静态链接的二进制文件,需要添加验证条件–use-libraries

将命令:pod lib lint --allow-warnings
改为:pod lib lint --use-libraries --allow-warnings

第二种情况:

若是自己封装的库,依赖的第三方里面包含了静态库,直接修改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.`

此类问题一般是有platform :ios, '9.0’版本不一致导致的,可以检查版本号

问题十四
ERROR | name: The name of the spec should match the name of the file.

spec文件的名称有误,请检查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`
错误: PTBKeyChainStore没有找到 .h 文件

iOS [!] The repoXXPodsat../../../.cocoapods/repos/XXPodsis not clean

先移除本地索引库
repo remove XXPods

再从远程添加会来
repo add XXPods 索引库地址

问题十六
error: include of non-modular header inside framework module 'XXXStoreKit.XXDB':

框架模块XXXStoreKit.XXDB中包含非模块化头文件,即在XXDB中包含了非当前模块的头文件

解决办法就是:添加依赖

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]

查看私有库.h文件中引入方式是否是"MBProgressHUD.h", 如果是先改成 < MBProgressHUD/MBProgressHUD.h>

前提是:可以正常运行项目; 验证时使用:pod lib lint --allow-warnings

解决添加:–use-libraries

pod lib lint --allow-warnings --use-libraries

Could not build module ‘XXXPushKit’

问题十八 引入私有库报错.png

一般类似问题是因为私有库引用第三方SDK时,引用方式不正确导致;如果可以最好在.m文件引入,或者.h使用<>的方式

Include of non-modular header inside framework module ‘xxx’

描述:

在SDK开发过程中,我们自己的framework库中的一个.h文件引用了pod库中的类

这时候以源码的形式build是没有问题的,但是当build出静态库后,添加到其他项目中使用时,就报 Include of non-modular header inside framework module xxxx错误。

为什么会这样呢?
因为Xcode在默认情况下是不允许在framework中的头文件引入一个不属于任何Module的头文件。

普通解决:将Build Settings中的Allow Non-modular Includes In Framework Modules设为YES

方式二:
但是私有库别人集成可能就会有问题,此时建议添加以下配置,本质上和第一种方式类似;

 s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }
问题十九
ERROR | [XXXPushKit/XXXJPUSHService] file patterns: Thesource_filespattern did not match any file.

频繁 *** 作私有库podspec文件后,语法都没有问题;项目也可以正常运行;但就是在本地校验时失败;这时可能就是缓存春的问题,有时pod install 后不一定就可以,看起来没问题;事实上多次校验都无法通过。这时候需要清理下cocoapods缓存,清理工程xcode缓存是无效的;

直接前往:~/资源库/Caches/CocoaPods/Pods/
/Users/mac/Library/Caches/CocoaPods/Pods/External/XXXPushKit/349f5495df6442f748c403e90110e181-5ff3a

删除掉XXXPushKit文件,重新走校验流程;如果还是不行,可以直接尝试把私有库的XXXPushKit文件拷贝到349f5495df6442f748c403e90110e181-5ff3a中,即可通过校验

问题二十
示例.png
- ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for AliPlayerSDK_iOS depended upon by XXXX

项目模块化时,我们制作的私有库免不了依赖其他私有库和CocoaPods的公有库。在产品更新迭代制作新版本的私有库后,准备提交私有库前的验证环境如果没有给验证私有库的命令知道地址一般都会报如下错误。但是如果项目中如果只有公共库应该不会报错,因为验证和提交的时候默认回去官方specs库校验,目前写的库还没有只依赖公有库的。

校验podspec文件时会到远程podspec库查找相关依赖,默认只会到官方specs库校验,此时需要指定远程specs库去校验。

podspec文件在写依赖的时候也无法在对应的库后面添加源地址。但是我们可以在验证和提交的时候加上–sources参数。注意–sources后面也需要加上官方源,不然会报找不到公开的第三方库。

pod spec lint --verbose --use-libraries --allow-warnings --sources=‘git@私有库地址.git,https://github.com/CocoaPods/Specs.git’

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/994121.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存