0

我正在 Xcode 中的多个库上构建静态 iOS 框架。其中之一应该是card.io。我不能使用 cocoapods 或 carthage。到目前为止,我在 .framework 中导入了 .frameworks 并且效果很好。然而 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 库和头文件的实现。目前我不能保证它会在基于我的框架的版本中工作,所以我会更新这篇文章以确认它。我希望它可以帮助某人...

4

0 回答 0