3

I'm developing a static library where i need to use the open source SBJson class.

what is the best way to include the SBJson class to my library without needing to include all its header files(.h) when distributing my static library ??

Thomas_LEB
  • 239
  • 5
  • 12
  • Do the clients of your library need the SBJSON functionality directly? If so, you'll need to supply headers for it. If not, you shouldn't have to. – Ben Zotto Feb 19 '12 at 02:15

2 Answers2

1

If your creating a static library, any application that uses that static library will need to know of all the public methods avaliable to said library.

If SBJson is an internal part of your library then you don't have to include its headers files when distributing the application. You only have to include the .h files of the public facing methods.

When compiling your static library, just don't include the header files for SBJson under the copy files stage.

richerd
  • 1,247
  • 11
  • 10
1

The best way is not to (attempt to) hide the dependency, and then tell the clients they will need to build and link to the SBJson library.

The safe alternative would be a fork of SBJson with all symbols redeclared as different names (e.g. a unique prefix). This will ensure your client has zero hassle linking your library with their dependencies.

justin
  • 104,054
  • 14
  • 179
  • 226
  • this is what i was thinking to do. this will also prevent any conflict with another static library which could also use the same library – Thomas_LEB Feb 19 '12 at 05:28
  • Is there a way of prefixing programmatically without going in by hand and adding a prefix to all the symbols? – Liyan Chang Jul 16 '12 at 20:33
  • @LiyanChang not safely (consider link and/or runtime collisions if the client also uses the library). if you use the refactor tools in Xcode, it should go quite quickly. – justin Jul 17 '12 at 06:29