在静态框架内链接动态库

时间:2018-07-31 11:59:55

标签: swift xcode frameworks cardio

我正在Xcode的多个库上构建静态iOS框架。其中之一应该是card.io。我不能使用cocoapods或迦太基。到目前为止,我已将.frameworks导入.framework中,并且效果很好。但是card.io使用带有头文件的静态库(.a文件)。它在.frameworks的动态类型(或iOS应用程序项目)中效果很好,但是在静态项目中,我在包含.a文件时遇到了这些错误:

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

关于这些错误,我下载了card.io的源代码,它看起来有动态的.framework目标正在等待构建。我尝试使用此文件而不是.a文件和标头-因此至少可以构建我的项目。因为card.io并不冲突模拟器的体系结构(顺便说一句,它应在此版本5.2.2中使用),所以我无法在单元测试中对其进行测试,因此当我在设备上测试该解决方案时,我得到了此错误:

dyld: Library not loaded: @rpath/CardIO.framework/CardIO
  Referenced from: /var/containers/Bundle/Application/55D3AF7F-83F4-4B3D-A667-0FCO93CCC441/App/AppDemo
  Reason: no suitable image found. 

到目前为止,我的知识+ google + stackoverflow停留在这里,因为看起来xcode不支持.framework中的.framework。

到目前为止,我花了两天时间处理这个“问题”,所以问题是:是否存在将动态库包含到静态框架中的解决方案?还是将card.io纳入静态框架的任何解决方案?

编辑:

实际上,解决方案比我想象的要愚蠢(一如既往)。只需要将card.io包含在.framework中,请转到“项目说明->构建设置->库搜索路径”,然后键入xcode查找库的路径。这种方法解决了该文章的第一个问题-这意味着.a库和标头的实现。 目前,我不能保证它可以在基于我的框架的发行版中使用,因此我将更新此帖子以在以后进行确认。我希望它可以帮助某人...

0 个答案:

没有答案
相关问题