iOS build does not export all SDL functions

This is more an Xcode/iOS question than an SDL question, but somebody here may know the answer. In my app I do some ‘late binding’ of SDL functions, that is I call ‘dlsym’ (SDL_LoadFunction would probably work just as well) to discover their addresses at run-time rather than statically linking to them.

This works fine on most platforms, presumably because (whether downloaded as a pre-built binary or compiled from source) SDL2 exists in the form of a shared .dll or .so file which exports everything. But on iOS the only SDL functions recognised by ‘dlsym’ are those that are linked at build time; the rest are apparently not exported.

Can I make some change to my Xcode/iOS build process which will cause all SDL functions to be exported and thus available for late binding at run time?

The linker flag force_load will keep the symbols from a statically
linked library. Use the flag for each library you want to keep symbols
for, e.g.
-force_load libsdl.a

-all_load can also be used, but will pull in everything from all your
libraries. But this sometimes causes problems if you have lots of
libraries, so -force_load is much better.

-Eric

Thanks, I’ll try that. I found a workaround using an ‘exported symbols’ file - a text file containing a list of the symbols you want to be exported - into which I copied all of SDL’s functions (except those implemented as macros of course)! But your solution sounds neater.