Trouble running Examples
ekmekjian opened this issue · comments
I'm trying to implement some of the examples
import Foundation
import SwiftTUI
struct MyTerminalView: View{
var body: some View{
Text("Hello, World")
}
}
struct ContentView: View {
@State var counter = 1
var body: some View {
VStack {
Button("Add number") { counter += 1 }
if counter > 1 {
Button("Remove number") { counter -= 1 }
}
ForEach(1 ... counter, id: \.self) { i in
Text("Number \(i)")
}
.border()
}
.padding()
}
}
@main
public struct swiftodo {
public static func main() {
Application(rootView: ContentView()).start()
}
}
but I'm having some trouble trying to get the code to run.
When I try to run this in Xcode I get the error
�[?1049h�[2J�[1;1H�[?25lSwiftTUI/Application.swift:141: Fatal error: Could not get window size
2023-02-15 12:12:24.571150-0500 swiftodo[33848:757148] SwiftTUI/Application.swift:141: Fatal error: Could not get window size
(lldb)
When trying to get this to run using swift run
It gives me an error about @main
with Users/black/swiftodo/Sources/swiftodo/swiftodo.swift:25:1: error: 'main' attribute cannot be used in a module that contains top-level code
. So I remove the @main
and swift run gives me no errors but doesn't execute the program. I did init the project as an executable. Any and all help appreciated.