Question

I have a Cocoa-based universal dynamic library that also includes more static libraries, from which I want to export functionality. It seems I cannot do the latest without using an export symbols file, and this is fine by me ... somehow. I don't use anywhere the setting "Symbols Hidden by default" (GCC_SYMBOLS_PRIVATE_EXTERN, -fvisibility=hidden). The problem appeared when I was trying to export a base class from the dynamic library, more specifically when trying to use its members in derived classes not included in the library and even more specifically in the 64-bit build: " Undefined symbols: "_OBJC_IVAR_$_PluginBase.fConn" " I am aware of the 64-bit changes: http://developer.apple.com/library/mac/#releasenotes/Cocoa/RN-ObjectiveC/_index.html, section "64-bit Class and Instance Variable Access Control"

And, of course, everything works if I add _OBJC_IVAR_$_PluginBase.fConn to the export file ... but only for the 64-bit build, the 32-bit one doesn't know about such things: " Undefined symbols: "_OBJC_IVAR_$_PluginBase.fConn", referenced from: -exported_symbol[s_list] command line option "

The only solution seems another workaround: to have two export files. But ... I cannot use "Add build setting condition" for EXPORTED_SYMBOLS_FILE setting :-S.

Any ideas (besides using public accessor methods) ?

Was it helpful?

Solution

You can make architecture-conditional build settings using xcconfig files. It looks like it's not possible through the GUI. Create a Build Configuration file containing the following:

EXPORTED_SYMBOLS_FILE[arch=i386]=$(SRCROOT)/SymbolsList32Bit
EXPORTED_SYMBOLS_FILE[arch=x86_64]=$(SRCROOT)/SymbolsList64Bit

and then in the Project settings, set that file to be the build config for the project and you should be good to go. (Obviously you'll have to make the paths point to your files, but hopefully you get the idea.)

It worked for me. (FWIW you can also conditionalize on SDK name, like MY_SETTING[sdk=iphoneos*]=FOO, MY_SETTING[sdk=mac]=BAR, etc.)

Hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top