Making Your App Extensible with JavaScriptCore (CocoaHeads Presentation)

I recently went to CocoaHeads Aachen and was asked if I happened to have a topic to talk about. Of course I did :) Designing plugins for The Archive took up a lot of my time this year. So this presentation is about the basic design of the plugin system as registered inputs/outputs.
Patching console.log into Swift's JavaScriptCore JSContext
By default, you cannot print to the Xcode console from within a JavaScriptCore-evaluated script. print
, echo
, console.log
– nothing of the like is available. Caveman debugging is tremendously useful, though, so we all know that we want to print from the JavaScript we evaluat, right?
Add Subscripts to JavaScriptCore Types in Swift
The JavaScriptCore framework was apparently very convenient to use in Objective-C times: you could simply use subscripts to change objects inside the context, like this: In Swift, tutorials you find on the web stick to the longer version that underlies the subscript convention here: method calls to -objectForKeyedSubscript
and -setObject:forKeyedSubscript:
.