Re:What is the best way to solve an Objective-C namespace co...
by krevis on Sunday May 20, 2012 @01:57AM
(#3998076)
About that category issue: you know about the -all_load and -force_load linker flags, right?
c.f. the "Important" box in http://developer.apple.com/library/mac/#qa/qa1490/_index.htm...
Re:What is the best way to solve an Objective-C namespace co...
by SeoxyS on Sunday May 20, 2012 @04:54AM
(#3998329)
Yes, but that's a flag that our library's users would have to figure out how to add to their project. And if they forget to, it would create crashes at runtime. That's not a can of worm we were willing to open.
Re:What is the best way to solve an Objective-C namespace co...
by thought_alarm on Sunday May 20, 2012 @04:47AM
(#3998322)
Namespaces don't really solve that problem, do they?. Your options are to either fork SBJson and give it its own namespace/prefix, or require SBJson as an external dependency and lets your users provide their own version of the framework.
Re:What is the best way to solve an Objective-C namespace co...
by wsc981 on Sunday May 20, 2012 @07:15AM
(#3998515)
I prefer if SBJSON is an external dependency, since there's less chance that I need to modify external projects my own projects make use of. The downside of course is that not all external projects might use the same version of SBJSON, so method names could have changed, could be missing, etc... So it falls to the developer to provide patches to external libraries if they use an outdated version of a library like SBJSON.
Still, this is for me the preferred approach.
As the developer behind one of the ad network SDKs included in countless iOS apps, I struggled finding a good solution to this problem. Spoiler: there isn't one.
The good news is, while there were often collisions on SBJson; pretty much all versions of the version are compatible. For a while, we would compile our static library without the SBJson objects, and ship the library and SBJson separately.
Recently we decided to create our own fork of SBJson, and switch to using our own prefix, which allowed us to embed it in our library, and not worry about what other libraries were doing.
Note: another tricky gotcha with static libraries for iOS: There is a bug in the linker, in that it will not import Objective-C categories from `.o` files unless there is another another symbol that is recognized, such as a class of C function. This has caused crashers and much headache.