小知识,大挑战!本文正在参与“程序员必备小知识”创作活动
通过问题看本质!!!
CocoaPod库制作过程中遇到的一些坑点
1、远程验证不通过
本地的私有仓库验证通过,但是远程仓库上的私有仓库验证不通过
- 路经不对
Error[iOS] file patterns: The `source_files` pattern did not match any
解决办法:重新打开xxx.podspec文件编辑一下,确定共享文件路径没有错误,然后再上传到github上验证。
- 上传xxx.podspec到github和给xxx.podspec打tag顺序搞反了,远程验证不通过 解决办法:必须先将本地文件夹所有的文件上传到github上
git add .
git commit -m"add all"
git push origin master
然后再给xxx.podspec打上tag,并上传
git tag -m "注释" 1.0.0
git push --tags
2、pod库依赖包含.framework静态库问题
当自己的pod库依赖了包含.Framework的pod库时,在使用时执行这个pod install会报错,使用这个库的时候也会报这个错。
es:制作pod库直接依赖高德的pod库时,包含s.source_files配置,也出现这个错误;不包含s.source_files没有这个错误
[!] The 'Pods-Test' target has transitive dependencies that include static
binaries: (/Users/admin/Desktop/Test/Pods/AMap3DMap/MAMapKit.framework,
/Users/admin/Desktop/Test/Pods/AMapLocation/AMapLocationKit.framework,
and /Users/admin/Desktop/Test/Pods/AMapSearch/AMapSearchKit.framework)
解决办法:这个得在工程的podfile文件里加上下面这句话:
target 'CLTSwiftLib_Example' do
......
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end
end
3、Swift库的相关类、属性、方法无法访问
在创建swift的pod库时,需要公开的类、属性、方法,需要用public修饰,否则在工程中无法访问。又是一大坑。
4、pod库仓库与工程仓库共用search不到
本地和远程验证都通过,也成功push了,但是pod search却找不到。
解决办法:在制作私有pod库时,要将仓库和工程分开建立,否则会出现验证通过,却找不到库的问题,本文制作的私有库就是将pod仓库和项目仓库分开,便于管理。
5、使用封装好的pod库,报类在两个地方实现
使用直接依赖高德pod库,封装好自己的高德pod库,在工程中使用时会报
Class AMapInitRequestReformer is implemented in both /Users/admin/Library/Developer/CoreSimulator/Devices/3D47A858-C1C7-40D2-8D92-139E3E403BE0/data/Containers/Bundle/Application/2C044E8E-6927-4EAD-B6D3-8BCEBDFE69DA/podMap_Example.app/Frameworks/podMap.framework/podMap (0x1035eae10) and /Users/admin/Library/Developer/CoreSimulator/Devices/3D47A858-C1C7-40D2-8D92-139E3E403BE0/data/Containers/Bundle/Application/2C044E8E-6927-4EAD-B6D3-8BCEBDFE69DA/podMap_Example.app/podMap_Example (0x1014dd7a0). One of the two will be used. Which one is undefined.