JavascriptCore Linux Support

Hello,

I am evaluating using Swift for a project that needs to run on both macOS and Linux. However, I noticed that JavaScriptCore does not seem to be available for Linux, at least as of Swift 5.0.2. Is there some sort of road map or documentation somewhere to determine if there is planned support or work being done to support it in the future at some point? Thanks.
-joe

JavaScriptCore is an Apple framework that's not part of the Swift open-source project, but distributed as part of Apple's operating systems, so it's unlikely that there would be a public release of it for Linux.

If you want to integrate Javascript into a Swift project on Linux, you'll probably want to take an engine like V8 and figure out how to call into it. I think V8's bindings are C++, so you'd have to write a little bit of glue code in C because Swift can't directly import C++. I don't know if anyone has done anything like that already.

Thanks, this is helpful.

I checked out JavaScriptCore in the Webkit repo, and I noticed that there is a modulemap there. Webkit currently builds on Linux, so it seems like it would just be a matter of updating the modulemap, or something about JavaScriptCore to build on Linux along with the rest of the project. In any case, this is probably a better question for that project instead.

And thanks for the tip on V8. I did look into that as well, but when I saw it was C++, I gave up on that route because I didn't think C++ could be linked to Swift projects. Could you point me in the right direction to get started with how I'd write C code to link into C++? I haven't written C code since the 90s, and never wrote C++.

Terms of Service

Privacy Policy

Cookie Policy