Skip to content

Instantly share code, notes, and snippets.

@YutoMizutani
Created December 18, 2018 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YutoMizutani/eb2134ecbc5e8130342efff70553092d to your computer and use it in GitHub Desktop.
Save YutoMizutani/eb2134ecbc5e8130342efff70553092d to your computer and use it in GitHub Desktop.
LinuxでもSwiftを使ってGUI開発をしたい!【SwiftGtk】 ref: https://qiita.com/YutoMizutani/items/a550b6fa5767a7c55eea
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-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "test",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/TomasLinhart/SwiftGtk", "0.3.1" ..< "0.4.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "test",
dependencies: ["SwiftGtk"]),
.testTarget(
name: "testTests",
dependencies: ["test"]),
]
)
$ mkdir test && cd $_
$ swift package init --type executable
$ vi Package.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment