NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore

Home Page:http://docs.nativescript.org/runtimes/ios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metadata found but symbol not available at runtime - Workaround "EXPORTED_SYMBOLS_FILE" is not working

manuelfrey opened this issue · comments

At the moment I have a problem which looks similar to #1061. But the described workaround is failing in my solution.

My scenario:
I would like to create a NativeScript Plugin. The Plugin should contain an objective C clas which wraps a c++ class. For testing purpose it is just a simple getnumber method ehich return a simple number an other method returns a string.
I am using NativeScript 6.1.2.

I tried the following:

1.) I built an 'fat' dynamic framework with XCode and an objective C clas, The check with lipo returns the following info:
Architectures in the fat file: test3 are: x86_64 i386 armv7 armv7s arm64

2.) I included it in my Nativescript plugin and started the demo app

declare const MyNative: any;

const native = new MyNative();
const res = native.getNumber();

3.) In My demo app I always got the error message:

"Metadata for 'test3.MyNatuve' found but symbol not available at runtime."

4.) I searched with google and found the issue '#1061' and tried to solve it in the same way

I called the following command
nm --defined-only test3 | grep " T " | cut -f 3 -d' ' | egrep -v '^$|test3' > test3_defined

The content looks like:

__ZN8MyNative10getCppTextEv
__ZN8MyNative16getCppStaticTextEv
__ZN8MyNative9getNumberEv

...and extendend the buildxconfig with the folloing lines:

STRIPFLAGS=$(inherited) -s ${PROJECT_DIR}/../../../src/platforms/ios/test3_defined
EXPORTED_SYMBOLS_FILE = ${PROJECT_DIR}/../../../src/platforms/ios/test3_defined

(The path must be correct, if I change it I got an error message withw rong path)

5.) I can rebuild and run the demo app without errors. But if I call the function I got the error again:
"Metadata for 'test3.MyNatuve' found but symbol not available at runtime."

I don't have any ideas any more to solve this problem or just to find further informations.

Thanks in advance for any hints or assistance.

Hi @manu-f, as far as I can see you are trying to directly access a C++ class (MyNative) from JavaScript. NativeScript's iOS bridge, however, supports only Objective-C. In order to call your native methods, you have to wrap them in Objective-C @interfaces. I hope this sheds light on the issue, if you need any other directions, feel free to ask.

I recommend examining the iOS runtime documentation: https://docs.nativescript.org/core-concepts/ios-runtime/Overview

Hi @mbektchiev, thanks a lot for your fast response and this hint. You're right. I made the mistake that I just put the c++ - header file in the objective-c umbrella header. After I made a real objective-c class and wrapped the c++ class it works. 👍
And thank you very much for your offer to response to further questions.
Perfect! :-)