I am writing macOS Swift application with the following environment:
- XCode 12 and/or JetBrains AppCode 2020.2
- Swift 5
- macOS 10.15.7 Catalina
The Swift app has the following View code as its main UI;
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Hello")
Button(action: {
}) {
Text("Download")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
The application program compile and ran properly without errors or warning. However, when the application window loses focus (e.g., click the desktop or other application window) or getting focus after losing focus, the console shows the following errors:
2020-10-17 07:24:02.939 HelloAppCode[11611:207556] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2020-10-17 07:24:02.939 HelloAppCode[11611:207556] Text input context does not respond to _valueForTIProperty:
2020-10-17 07:24:02.939 HelloAppCode[11611:207556] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2020-10-17 07:24:02.939 HelloAppCode[11611:207556] Text input context does not respond to _valueForTIProperty:
But, when the Button is removed from the View, i.e.:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Hello")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
No errors are showing from the console. The error messages also appear if another control such as TextField is used.
I am new to Swift and macOS app development, so I wonder if I did something wrong with the code? How to properly write the code with Buttons and TextFields without causing the errors to show up on console?
Thank you.
This problem is not related to the Swift code at all. I code the Swift application with Japanese input source on macOS because my keyboard layout is Japanese, hence the error messages are shown on Terminal/console when the application window get/lost focus.
Changing the Input Sources to
English - ABC
solves the problem. You can change the Input Sources from macOSSystem Preferences - Keyboard
. Add or change the Input Source toEnglish - ABC
fromInput Sources
tab.PS: The error messages also shown on Terminal when ElectronJS app ran from it. Changing the Input Source also solves the problem. I wonder if it's a bug from non-English input sources of macOS?