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

swift method throwing having wrong typings, can't run

farfromrefug opened this issue · comments

I am trying to modify a swift library so that it can work with {N}
https://github.com/Akylas/NextLevel

The idea was to add a few @objc ...

It almost all work flawlessly except for one method
The start throws an error.
I modified the Error type so that it is exposed too. But the typings resulting is wrong.
I end up with this

	startAndReturnError(): void;

As you can see this is the correct method name but the error argument is missing.
Can't find out why.

Anyone can help?

Hi @farfromrefug,

You need to convert the Swift error type into a NSError. Many swift objects CANNOT go over the bridge into ObjC, if they can't bridge to ObjC they can't bridge to NativeScript. It is safest when dealing with Swift to use "Int", "NSString", "NSArray", "NSDictionary", etc and make sure your bridged types are of the standard ObjC types. Any swift structures, classes, enums are very very likely to not bridge into ObjC.

By the way when the meta data system can't figure out a compatible type it just removes it.