JavaScript/Swift Interoperability

I think that it would be helpful to have better interoperability between Swift and JavaScript. There are a lot of useful packages on NPM that don't have equivalents for Swift. It would be helpful if Apple provided easier ways to use NPM packages in a Swift project. Currently, the JavaScriptCore framework is missing many standard things used in many packages, like the fetch API. It would be helpful to be able to run sandboxed JavaScript code inside of a Swift app but allow access to specific domains, folders, etc., using a permissions system similar to Deno.

Answered by DTS Engineer in 871859022
Are there any other places that I should post this to get more discussion?

I can think of least two:

  • JavaScriptCore is open source as part of WebKit project, and they have their own community discussions.
  • Likewise, Swift is open source and has Swift Forums.

The best approach kinda depends on who you want to do the work. If you just want Apple to fix something, Feedback Assistant is your best option [1]. But if you want to engage with other developers then things get more nuanced, especially with regards to where the changes land, which is a big factor in what work gets done and who does it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] For more about that process, see Bug Reporting: How and Why?.

And if you do file this in Feedback Assistant, please post your bug number, just for the record.

If you have a suggestion, you should raise it at: https://feedbackassistant.apple.com/

When doing so, I recommend you list the specific APIs you want, and the justification for them. A suggestion that Apple just implement some of the missing APIs won't get very far.

I would like to discuss this general idea with other developers before filing feedback for specific APIs. Are there any other places that I should post this to get more discussion?

Are there any other places that I should post this to get more discussion?

I can think of least two:

  • JavaScriptCore is open source as part of WebKit project, and they have their own community discussions.
  • Likewise, Swift is open source and has Swift Forums.

The best approach kinda depends on who you want to do the work. If you just want Apple to fix something, Feedback Assistant is your best option [1]. But if you want to engage with other developers then things get more nuanced, especially with regards to where the changes land, which is a big factor in what work gets done and who does it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] For more about that process, see Bug Reporting: How and Why?.

And if you do file this in Feedback Assistant, please post your bug number, just for the record.

What would be the best category to post this in on the Swift Forums?

I’m a ‘guest’ on Swift Forums, just like you, so I don’t have a definitive answer. The options that spring to mind are:

The first makes more sense if you think this change should go into Swift itself. See here for more info about the Swift Evolution process. OTOH, the later would be best if you’d like to explore ideas about how to use existing Swift infrastructure to improve the JavaScript experience. And keep in mind that Swift has a lot of existing Cool Tools™ that can aid in these efforts.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

JavaScript/Swift Interoperability
 
 
Q