0

I am building the static iOS framework upon multiple libraries in Xcode. One of them should be the card.io. I cannot use cocoapods or carthage. So far I imported .frameworks within the .framework and it works pretty well. However card.io uses static library (.a file) with bunch of headers. It works well in dynamic type of .frameworks (or iOS app project) but in static project I get these errors on including of the .a files:

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)

Regarding these errors I downloaded the source codes of card.io and it looks that there is dynamic .framework target waiting for build. I tried to use this one instead of .a files and headers - so my project at least can be builded. Because the card.io does not contatin architectures for simulator (which, by the way, it should with this release 5.2.2) I am not able to test it in unit tests, so when I test this solution on device I get this error:

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. 

So far my knowledge+google+stackoverflow is stuck here, because it looks that xcode does not support the .framework within .framework this way.

To this moment I spent two days with this "issue", so the question is: Does exist any solution for including dynamic library into static framework? Or any solution to include card.io into static framework?

EDIT:

Well actually the solution was more stupid than I would think (as always). Just to include card.io in the .framework go to "Project Description -> Build Settings -> Library search paths" and type the path where should xcode look for the libraries. This approach solves the first one issue of this post - this means the implementation of the .a libraries and headers. At this moment I cannot guarantee it will work in releases based on my framework so I will update this post to confirm it later. I hope it helps someone...

Jan R.
  • 213
  • 3
  • 11
  • 1
    AFAIK it is not possible. But if you're building a framework that depends on other frameworks, you can simply tell your framework's user to also import the required dependencies. – user3581248 Jul 31 '18 at 13:13
  • Thanks, unfortunately the project I am working on has that requirement to encapsulate everything into one (aka umbrella but not umbrella) framework. :-/ – Jan R. Jul 31 '18 at 16:03
  • Other solution could be to actually ask card.io to provide a statically linked lib for you... – user3581248 Aug 01 '18 at 13:10
  • Also, this is MIT so why not include the source of their code into your framework? Probably could be done via CocoaPods – user3581248 Aug 01 '18 at 13:11
  • Thanks for the ideas - actually this is specific of the project that it cannot use any kind of dependency management...:-/ Anyway I think I have solved it with help of skilled coleague (^^ in update of the post). – Jan R. Aug 01 '18 at 14:02
  • As a rule, "I am building the static iOS framework upon multiple libraries in Xcode" is incredibly dangerous. If this library is going to be given to outside groups, you are setting them up for very bad build problems if they independently include any of the frameworks you include. See https://stackoverflow.com/questions/7365578/why-are-umbrella-frameworks-discouraged/14382737#14382737 for more. This is the kind of thing that "works" until it suddenly explodes horribly. (If you're doing this only for one project, then it may be fine, but likely not worth the effort.) – Rob Napier Aug 01 '18 at 16:49
  • @RobNapier Thank you and yes, I am absolutely aware of how dangerous it may be or at least how unflexible, dependent and unstable solution it may be. The thing is that at my position I am not able to change that idea of the "bosses" until it really falls apart with another critical not solvable "idea"...you know...-_- – Jan R. Aug 02 '18 at 07:10
  • Understood; however this particular approach is impossible. A `.a` is just a bunch of concatenated `.o` files. It has no linking instructions that could be used to interact with dynamic libraries (which are much more complicated beasts). A requirement may overcome the fact that it is dangerous. But no requirement will overcome the fact that it is impossible. Best of luck! – Rob Napier Aug 02 '18 at 13:32

0 Answers0