When using ElementaryUI and BridgeJS combined compilation succeeds but runtime crashes on start with:
Uncaught TypeError: import object field '<project>' is not an Object
@View
struct Counter {
@State var count = 0
var body: some View {
div {
p { "Count: \(count)" }
button { "Increment" }
.onClick { count += 1 }
}.onAppear {
try? console().log("Hello from Swift!")
}
}
}
import JavaScriptKit
@JSFunction func console() throws(JSException) -> Console
@JSClass struct Console {
@JSFunction func log(_ message: String) throws(JSException) -> Void
}