How to add exported symbols?

I used RoboVM previously and I could define in robovm.xml a section exportedSymbols:

How could I achieve the same in MOE?

Because of this my MOE application is crashing due to symbols that are defined in bindings are actually missing. The symbols are in the c folder (@CVariable) and all such methods are actually returning constant strings.

Dear Amy,

There are 2 sides to your question:

Java Symbols

You can use ProGuard to specify which symbols to keep in the project.

Native Symbols

Are you linking the C library statically or dynamically (e.g. using a dynamic framework)?

In either case it is not enough just to add the Java bindings to the project, you also have to add the native library to the Xcode project separately. The reason for this is that with MOE you can choose how to do the second part: e.g. add them manually from Xcode, or use CocoaPods or Carthage as a dependency management system.

If you are linking statically, and you only use these symbols from Java through Nat/J, then you have to force the linker to keep these symbols using the -force_load option.

If you are linking it as a dynamic framework (and it is added to the Xcode project), then Nat/J should find the symbols out of the box.

Could you please confirm that the symbols are present in the main binary (or in the included dynamic frameworks) of the built app?

If they do, and you still get the error, could you please provide us with a test project that we could take a look at?

Best Regards,

Well in that case what will happen ?
Will all the library be linked ?
IF I need 1-2 symbols from 10 mb library will I have all 10m in my executable ?
How to strip all the trash I dont need ?


In my project I added bindings for a few frameworks and they seem to be working just fine, except for Vungle 4.1.0.
In fact, the symbols are only missing in release build, while in debug build everything seems to be ok.

The symbols that I am using are constants like VunglePlayAdOptionKeyIncentivized, VunglePlayAdOptionKeyUser, etc.
I also print the SDK version with VungleSDKVersion, but that’s also missing in release build.

I use the VungleSDK as a framework, and I have added the framework to the Xcode as well.
Whet I check for the symbols in the library in the framework, they seem to be there:

$ nm -gU VungleSDK | grep VunglePlayAdOptionKeyIncentivized
---------------- S _VunglePlayAdOptionKeyIncentivized
---------------- S _VunglePlayAdOptionKeyIncentivizedAlertBodyText
---------------- S _VunglePlayAdOptionKeyIncentivizedAlertCloseButtonText
---------------- S _VunglePlayAdOptionKeyIncentivizedAlertContinueButtonText
---------------- S _VunglePlayAdOptionKeyIncentivizedAlertTitleText

nm -gU VungleSDK | grep VungleSDKVersion
---------------- D _VungleSDKVersion

Currently, in the MOE project I just got the values in debug mode and hardcoded them, so my release version works, but that seems to be a dirty workaround.
For this same framework in RoboVM I used exportedSymbols and added all these symbols there and that made it work.
I am not sure if I should add some other flag or something else to the project in order for this to work in MOE.

Yes. If you have a 10MB static library, and you only need 2 symbols from it (and those symbols don’t depend on the rest of the library), then one option would be of course to split it to a separate library.

If this is not feasible, then one needs to find a way to tell the Xcode linker which of these symbols are required even if they are not explicitly called. One can use for example export lists, and we are experimenting with this for MOE 2.x, but it is currently untested for MOE 1.x.

Another idea (code name for ugly hack), that I just thought of could be something like this:

int main(...) {

int x = get_value_from_info_plist("NonExistentKey");
if (x == 42) {
    // This code will never run, but the compiler / linker does not know this
// Rest of main()

Yes this is ugly, so I don’t recommend it, but could get the job done.

This is definitely weird, we will take a look at VungleSDK. Thanks for the detailed report.

What if a obj class overides NSArray method. How can I link that ? Instatiate it in a unreachable code ?

To make my question more clear, lets see to the example:

this file adds methods to NSDictionary, how can I link it so that it wont be stripped by linker ?