1

My iOS project used a 3rd party (not open source) static library (i.e. libA.a), and this libA.a used CocoaLumberjack, it compiled CocoaLumberjack directly into itself, and the version of CocoaLumberjack is unclear.

Now I also want to use CocoaLumberjack to track logs in my program, and it will result duplicate symbol errors if I install CocoaLumberjack via CocoaPods.

Questions:

  1. Is there a way to hide the CocoaLumberjack symbols in libA.a so that Xcode won't report symbol errors?

  2. Any other file logger libraries that can be recommended?

Now I am looking through symbols in libA.a, contrasting it with the source of CocoaLumberjack, and I am closed to find the version of CocoaLumberjack libA.a used, my next step should be only including header files of CocoaLumberjack in my project. It should work, but I don't like this way.

Hao Xi
  • 351
  • 4
  • 12
  • Just a update. Finally we get the author of libA.a to remove the old version of CocoaLumberjack from their library. – Hao Xi Nov 27 '16 at 07:27

1 Answers1

0

You can unpack the object files from the static library and repack it without the CocoaLumberpack object files.

Something like:

$ ar x libA.a
$ rm cococaLumberjackFile*.o      # Whatever they are called
$ ar cr libA.a *.o

If the static library is fat (contains multiple CPU architectures) then this becomes much more difficult and involves lipo and much pain.

EDIT: Just go ahead and use CocoaLumberjack in your code and link with libA.a. It will provide the objects for both the 3rd-party library and CocoaLumberjack.

Droppy
  • 9,691
  • 1
  • 20
  • 27
  • It looks pretty cool. However, it is possible that `libA.a` is also using `CocoaLumberjack`, if I removed them, I doubt if `libA.a` code will work with latest version of `CocoaLumberjack` or not (because of various changes in methods, etc.). But if I can find out which version of `CocoaLumberjack` `libA.a` used, then I can use your method to include source of `CocoaLumberjack` into my project. – Hao Xi Oct 10 '16 at 12:28
  • Give it a try and find out. – Droppy Oct 10 '16 at 12:29
  • Hmm.. Doesn't work. It says `ar: libA.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it) . ar: libA.a: Inappropriate file type or format` – Hao Xi Oct 10 '16 at 12:32