sketch-hq / SketchAPI

The JavaScript plugin library embedded in Sketch
https://developer.sketch.com/reference/api
MIT License
843 stars 127 forks source link

Always 0 when evaluate Objective-C Enum value of Sketch on MacOS10.15Beta #558

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello, I have found a problem; but I don't know why.

from MacOS10.15Beta, SketchApp Run Script:

const r = NSUTF8StringEncoding

console.log(r)

The result always 0, no matter what Objective-C Enum value here;

But MacOS10.14, MacOS10.13, is OK; when this case, value is 4, 4 is correct from documentation of Xcode.

So I have to manually replace all Objective-C enum value to integer, in order to make plugin works on MacOS10.15Beta; that's not so good.

mathieudutour commented 5 years ago

Indeed, that's a weird bug. We are looking into it

huw commented 5 years ago

To clarify, this is affecting all Objective-C enums, which breaks almost every plugin. You can't ship for 10.15 without fixing this. It's still broken in the latest Catalina beta.

I assume it's because Mocha isn't setting the value properly, so it's defaulting to whatever the NSInteger default is (0). I tried to work with that codebase, but ran into a lot of compiler errors (I assume you're building your own internally).

The code in question is probably https://github.com/logancollins/Mocha/blob/ccc18bf89a044f78bb332a8b8854f2d779e1ce57/Mocha/BridgeSupport/MOBridgeSupportParser.m#L145. It could be to do with recent, underdocumented API changes to NSNumber.

mathieudutour commented 5 years ago

It’s not no. It was because of a typo in CocoaScript: https://github.com/ccgus/CocoaScript/pull/63

It will be fixed in an upcoming version of Sketch but keeping it opened for people to be able to see it

huw commented 5 years ago

Huh! Thanks for solving it — do you think this'll land with Sketch 56?

mathieudutour commented 5 years ago

I don’t think so, Sketch 56 has been code freezed already and we still have to fix our infra for 10.15. But 57?will follow shortly after!

huw commented 5 years ago

I gave this a go on Sketch 57 Beta 1 — it looks like the same problem is still happening. I assume I should wait for Beta 2 or 3?

hadihallak commented 5 years ago

Same here. for example, webview plugins still appear borderless (no window or window controls)

mathieudutour commented 5 years ago

I just merged the fix so yeah, next beta :)

robintindale commented 5 years ago

Just testing this on the latest prod / latest beta, I'm seeing windows and controls, but close is not working. The window is staying open despite clicking the close control, and if I try and close the window from within the webview with this.window.close, it says this.window is null. Verified this with sketch-dev-tools and a window from our own plugin

mathieudutour commented 5 years ago

I just updated the dependencies of sketch-dev-tools and it seems to work fine.

It might have been a bug fix in sketch-module-web-view

robintindale commented 5 years ago

Hmm I've updated my sketch-module-web-view and get the same behavior. Will create a new issue over there 👍