ios-jsc icon indicating copy to clipboard operation
ios-jsc copied to clipboard

swift method throwing having wrong typings, can't run

Open farfromrefug opened this issue 6 years ago • 1 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?

farfromrefug avatar Feb 02 '19 08:02 farfromrefug

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.

NathanaelA avatar Feb 02 '19 08:02 NathanaelA