您的位置:首页 > 大数据 > 人工智能

cocoa pod 制作私有静态库时写完codspec文件又遇到了linker command failed却没有具体错误原因的问题

2015-06-01 15:54 639 查看

前提:

公司有个常用项目要制作成libVideo.a(所有文件名均为化名)的静态库,需要引用到libSocket.a的静态库和公司的另一个customImage.framework。

公司都是用的svn保存源码。

任务:

现在我要把libvideo.a这个库的源码制作成pod的私有源。这样在新的产品要引用libVideo.a的时候直接在podfile中引用就好了。

坑点:

pod spec create libVideo 之后,一顿痛改spec文件,列一些坑点如下

部分代码是arc部分代码是mrc,各占一般,而且是随机分布在各个目录中的。如下解决

#这里只列出两个文件作为例子
non_arc_files = 'libVideo/SBJson/*.{h,m}',
'libVideo/Utility/XXXUtility.{h,m}'

s.source_files  =  'libVideo/**/*.{h,m}','libVideo/list.xcdatamodeld'
s.exclude_files = non_arc_files
s.requires_arc = true

s.subspec 'no-arc' do |sna|
sna.source_files = non_arc_files
sna.requires_arc = false
end


要用到libSocket.a和customImage.framework。

s.ios.vendored_frameworks = "libVideo/customImage.framework"
s.ios.vendored_libraries = 'libVideo/libSocket.a'


最后pod spec lint libVideo.podspec文件的时候还出错:

- ERROR | [iOS] Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE  |  clang: error: linker command failed with exit code 1 (use -v to see invocation)


我又用-verbose去看,结果还是没什么详细信息,明明都build成功了,但是linker command failed,于是又去爬文,在pod lint libVideo.podspec后面还要加上 --use-libraries才通过lint。

目前做到这里,后面不知道还有哪些坑在等着我- =

几天后更新:

又遇到了这个错误:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods is not an object file (not allowed in a library)


这个错误在stackoverflow上好找:

在target的buildsetting中把build active archetectures only的debug改为yes,release改为no。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息