Use @main attributes (#378)

This commit is contained in:
noppefoxwolf 2022-09-14 19:38:59 +09:00 committed by GitHub
parent 2f462a4693
commit bdb5d5944a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -187,14 +187,22 @@ extension Templates {
],
terminal
)
try fileSystem.writeFileContents(project.path.appending(
try fileSystem.removeFileTree(project.path.appending(
components: "Sources",
project.name,
"main.swift"
))
try fileSystem.writeFileContents(project.path.appending(
components: "Sources",
project.name,
"App.swift"
)) {
"""
import TokamakDOM
@main
struct TokamakApp: App {
var body: some Scene {
WindowGroup("Tokamak App") {
@ -208,11 +216,6 @@ extension Templates {
Text("Hello, world!")
}
}
// @main attribute is not supported in SwiftPM apps.
// See https://bugs.swift.org/browse/SR-12683 for more details.
TokamakApp.main()
"""
.write(to: $0)
}

View File

@ -74,8 +74,8 @@ final class InitCommandTests: XCTestCase {
"Sources/\(package) does not exist"
)
XCTAssertTrue(
packageDirectory.ls().contains("Sources/\(package)/main.swift"),
"Sources/\(package)/main.swift does not exist"
packageDirectory.ls().contains("Sources/\(package)/App.swift"),
"Sources/\(package)/App.swift does not exist"
)
XCTAssertTrue(packageDirectory.ls().contains("Tests"), "Tests does not exist")
XCTAssertTrue(
@ -88,7 +88,7 @@ final class InitCommandTests: XCTestCase {
)
let actualTemplateSource = try String(contentsOfFile: packageDirectory
.appending(components: "Sources", package, "main.swift").pathString)
.appending(components: "Sources", package, "App.swift").pathString)
XCTAssertEqual(expectedTemplateSource, actualTemplateSource, "Template Sources do not match")
}
@ -98,6 +98,7 @@ final class InitCommandTests: XCTestCase {
"""
import TokamakDOM
@main
struct TokamakApp: App {
var body: some Scene {
WindowGroup("Tokamak App") {
@ -111,10 +112,5 @@ final class InitCommandTests: XCTestCase {
Text("Hello, world!")
}
}
// @main attribute is not supported in SwiftPM apps.
// See https://bugs.swift.org/browse/SR-12683 for more details.
TokamakApp.main()
"""
}