【问题标题】:Swift with Electron on macOS在 macOS 上使用 Electron 的 Swift
【发布时间】:2016-11-27 10:15:45
【问题描述】:

是否可以在Electron 应用程序中调用和调试 swift 代码?

对于我的特殊情况,我想更改屏幕背景。

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)
}

【问题讨论】:

    标签: swift xcode macos electron


    【解决方案1】:

    不,但您可以将其编译为二进制文件并使用 child_process.execFile() 从 Electron 生成它。

    还有一个节点模块可以完成您想要实现的目标:wallpaper

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 2018-09-21
      • 1970-01-01
      • 2020-11-06
      • 2021-12-24
      • 1970-01-01
      相关资源
      最近更新 更多