Reputation: 2063
I am trying to use swift in archlinux. While attempting to build a simple project with Gtk, I run into some errors. Below is my Package.swift file:
import PackageDescription
let package = Package(
name: "SwiftGtkApplication",
dependencies: [
.Package(url: "https://github.com/TomasLinhart/SwiftGtk", majorVersion: 0, minor: 2)
]
)
And the main.swift file:
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)
}
I am unable to build it with 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
Both gtk and clang are installed. What am I doing wrong?
Upvotes: 2
Views: 178
Reputation: 2063
This is a simple matter of correctly pointing to the CGtk project within the SPM file with:
.Package(url: "https://github.com/TomasLinhart/CGtk-Linux", majorVersion: 1, minor: 3),
Upvotes: 1