Re: Migrating shared library plugins to Cocoa Touch Frameworks
Re: Migrating shared library plugins to Cocoa Touch Frameworks
- Subject: Re: Migrating shared library plugins to Cocoa Touch Frameworks
- From: Jean-Daniel <email@hidden>
- Date: Sun, 04 Dec 2016 23:23:42 +0100
> Le 4 déc. 2016 à 21:41, Andreas Falkenhahn <email@hidden> a écrit :
>
> I've now implemented plugin support using dlopen() in my app and
> it works fine so far.
>
> However, it seems like *all* symbols are exported to the dylib
> inside the Cocoa Touch Framework. How can I configure Xcode to
> export only certain symbols? I want to name the symbols that
> should be exported explicitly.
>
> When compiling normal macOS dylibs I don't use Xcode at all but
> makefiles. In that case, I simply use gcc's -exported_symbol_list
> argument to tell the linker which symbols should be made public.
> I could probably use this approach for Cocoa Touch Frameworks as
> well but I was wondering whether Xcode has a more convenient
> solution of marking symbols for export than using the -exported_symbol_list
> linker option. Is there any?
>
The best way if you don’t want to use a symbole file is to make all symboles hidden by default (using the GCC_SYMBOLS_PRIVATE_EXTERN Xcode build settings), and then annotate the exported symbols using the visibility attribute.
In practice, it means you should declared the exported symbols as follow:
__attribute__((__visibility__("default"))) extern void visible_function();
You can declare a macro to simplify such construct
#define MY_PLUGIN_EXPORT __attribute__((__visibility__("default"))) extern
MY_PLUGIN_EXPORT
void visible_function();
This attribute should also be set on obj-c class you want to export.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden