发布CocoaPods组件碰到的坑与心得体会(XLSpeechRecognition续)

项目地址:https://github.com/xiaoL0204/XLSpeechRecognitionDemo
CocoaPods地址:https://cocoapods.org/?q=XLSpeechRecognition
XLSpeechRecognition使用方法:pod 'XLSpeechRecognition', '~> 1.0.1'

关于发布CocoaPods库的方法和步骤可以参考这篇文章:发布CocoaPods组件碰到的坑与心得体会

写XLSpeechRecognition组件的时候,Demo工程能够顺利跑起来,达到了预期效果。但是在发布到CocoaPods时,碰到了好几个问题。现整理如下:

1.POP依赖库错误

The following build commands failed:CompileC /Users/xiaolin/Library/Developer/Xcode/DerivedData/App-egqnmoqsjdnegcgmcoojyjxcjkbz/Build/Intermediates/Pods.build/Release-iphonesimulator/pop.build/Objects-normal/i386/POPLayerExtras.o pop/pop/POPLayerExtras.mm normal i386 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler(1 failure) -> XLSpeechRecognition (1.0.0) - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. - NOTE | [iOS] xcodebuild: pop/pop/POPLayerExtras.mm:12:10: fatal error: 'TransformationMatrix.h' file not found[!] XLSpeechRecognition did not pass validation, due to 1 error. You can use the '--no-clean' option to inspect any issue.


根据终端错误提示,TransformationMatrix.h文件找不到。但是无论是重新buildrun或者cleanXcode工程都是没问题的,猜测pod lib lint命令验证与Xcode编译方式不同
既然报这样的错误,那就只能在工程中修改配置,让它验证通过。
原工程是workspacePOP依赖库是通过cocopods加入到workspace中的;无论修改Pods.xcodeproj中的配置,包括Pods工程的Build Phases -> HeadersCompile Sources都是报一样的错误,也修改了Build Settings中的Deployment TargetCompile Sources(修改为According to File Type)、Header Search PathsAlways Search User Pathsprefix headerswift version,都是workspace能正常编译运行,CocoaPods却验证不通过。
</br>
最后手动将POP库以文件夹的形式加入到工程中,修改Header Paths,将TransformationMatrix.cpp名称改为TransformationMatrix.mm,就没报这个错误了。

工程目录如下:

工程目录

2.源文件、资源文件找不到

xlmini:XLSpeechRecognitionDemo xiaoL$ pod lib lint -> XLSpeechRecognition (1.0.0) - ERROR | [iOS] file patterns: The 'source_files' pattern did not match any file. - ERROR | [iOS] file patterns: The 'resources' pattern did not match any file.[!] XLSpeechRecognition did not pass validation, due to 2 errors.You can use the '--no-clean' option to inspect any issue.


原因:是XLSpeechRecognition.podspec文件的问题,将s.resourcess.source_files修改如下就可以了:
s.resources = "XLSpeechRecognitionDemo/XLSpeechRecognitionDemo/XLSpeechRecognition/*.png" s.source_files = 'XLSpeechRecognitionDemo/XLSpeechRecognitionDemo/*.{h,m,mm,cpp}'

之所以这样配置,是因为我采用的工程的XLSpeechRecognition目录如下:

文件物理路径

podspec的配置需要随实际工程文件路径的改变而修改。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容