Linux 无法生成Objective-C模块';CGtk&x27;
我正在尝试在archlinux中使用swift。在尝试用Gtk构建一个简单的项目时,我遇到了一些错误。下面是我的Package.swift文件:Linux 无法生成Objective-C模块';CGtk&x27;,linux,swift,gtk,Linux,Swift,Gtk,我正在尝试在archlinux中使用swift。在尝试用Gtk构建一个简单的项目时,我遇到了一些错误。下面是我的Package.swift文件: import PackageDescription let package = Package( name: "SwiftGtkApplication", dependencies: [ .Package(url: "https://github.com/TomasLinhart/SwiftGtk", majorVer
import PackageDescription
let package = Package(
name: "SwiftGtkApplication",
dependencies: [
.Package(url: "https://github.com/TomasLinhart/SwiftGtk", majorVersion: 0, minor: 2)
]
)
import SwiftGtk
let app = Application(applicationId: "com.example.application")
app.run { window in
window.title = "Hello World"
window.defaultSize = Size(width: 400, height: 400)
window.resizable = true
let button = Button(label: "Press Me")
button.clicked = { _ in
let newWindow = Window(windowType: .topLevel)
newWindow.title = "Just a window"
newWindow.defaultSize = Size(width: 200, height: 200)
let labelPressed = Label(text: "Oh, you pressed the button.")
newWindow.add(labelPressed)
newWindow.showAll()
}
window.add(button)
}
以及main.swift文件:
import PackageDescription
let package = Package(
name: "SwiftGtkApplication",
dependencies: [
.Package(url: "https://github.com/TomasLinhart/SwiftGtk", majorVersion: 0, minor: 2)
]
)
import SwiftGtk
let app = Application(applicationId: "com.example.application")
app.run { window in
window.title = "Hello World"
window.defaultSize = Size(width: 400, height: 400)
window.resizable = true
let button = Button(label: "Press Me")
button.clicked = { _ in
let newWindow = Window(windowType: .topLevel)
newWindow.title = "Just a window"
newWindow.defaultSize = Size(width: 200, height: 200)
let labelPressed = Label(text: "Oh, you pressed the button.")
newWindow.add(labelPressed)
newWindow.showAll()
}
window.add(button)
}
我无法使用swift build
构建它:
/tmp/swift/.build/checkouts/SwiftGtk--3711260948702777640/Sources/Window.swift:5:8: error: could not build Objective-C module 'CGtk'
import CGtk
^
<module-includes>:1:10: note: in file included from <module-includes>:1:
(...)
/tmp/swift/.build/checkouts/SwiftGtk--3711260948702777640/Sources/Window.swift:5:8: error: could not build Objective-C module 'CGtk'
import CGtk
^
<unknown>:0: error: build had 1 command failures
swift-build: error: exit(1): /usr/bin/swift-build-tool -f /tmp/swift/.build/debug.yaml
/tmp/swift/.build/checkout/SwiftGtk--3711260948702777640/Sources/Window.swift:5:8:错误:无法生成Objective-C模块“CGtk”
导入CGtk
^
:1:10:注意:在文件中包括:1:
(...)
/tmp/swift/.build/checkout/SwiftGtk--3711260948702777640/Sources/Window.swift:5:8:错误:无法生成Objective-C模块“CGtk”
导入CGtk
^
:0:错误:生成有1个命令失败
swift构建:错误:退出(1):/usr/bin/swift构建工具-f/tmp/swift/.build/debug.yaml
gtk和clang都已安装。我做错了什么?这是一个简单的问题,正确地指向SPM文件中的CGtk项目,其中包含:
.Package(url: "https://github.com/TomasLinhart/CGtk-Linux", majorVersion: 1, minor: 3),
面对同样的问题,请让我们知道您是否可以解决此问题。现在,我的fork中正在正确构建此问题,请转到并将SPM中的链接更改为它。应该说这是Swift 4.1。