I'm making an app using SwiftUI and trying to use the TextEditor
view. However when I run it, and I try entering text into the TextEditor
, the characters don't appear, they do however appear in the terminal that i used to run the app. The same problem exists with the TextField
view.
I usually run it using swift run
but have also tried swift build
and running the produced executable as well as using release mode.
Minimal example:
import SwiftUI
@main
struct Example: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
@State var text: String = ""
var body: some View {
TextEditor(text: $text)
}
}
Swift Package Manager isn’t set up for building apps for Apple platforms. You can make it work in specific circumstances, but it’s not a supported path [1].
If you’re gonna build a Mac app, I recommend that you build it with Xcode. If you use some other tool for that, you’ll need to configure that tool to create a valid .app
bundle, one that matches the layout created by Xcode.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] If you search the ’net for “Swift Package Manager build mac app” you’ll find folks who’ve trodden this path before you.