Swift on Mac OSX


#1

Is it possible to invoke and debug swift code in an Electron app?

For my particular case, I’d like to change the background of my screen.

let sharedWorkspace = NSWorkspace.sharedWorkspace()
let mainScreen = NSScreen.mainScreen()
let url = NSURL(string: "path/to/my/image")!
do {
    try sharedWorkspace.setDesktopImageURL(url, forScreen: mainScreen!, options: [:])
} catch {
    print (error)
}

Stack Overflow question: http://stackoverflow.com/questions/38544576/swift-with-electron-on-mac-osx


#2

Electron doesn’t support any language other than JavaScript natively. You could create an executable that would change your background and then Electron could call it using the Node API.


#3

Answered on Stack Overflow.