问题描述:

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)

}

网友答案:

No, but you could compile it to a binary and spawn it from Electron using child_process.execFile().

There also exist a node module that does what you're trying to achieve: wallpaper

相关阅读:
Top