So I am trying to load a preview for a SwiftUI view, and it always fails with this error:
MessageSendFailure: Message send failure for update
==================================
| RemoteHumanReadableError: The operation couldn’t be completed. XPC error received on message reply handler
|
| BSServiceConnectionErrorDomain (3):
| ==NSLocalizedFailureReason: XPC error received on message reply handler
| ==BSErrorCodeDescription: OperationFailed
What does this mean and how can I fix it? The previews on my other views are working fine.
Here's the view in question:
import SwiftUI
@available(iOS 15.0, *)
struct EventEntryView: View {
@Environment(\.dismiss) var dismiss
let keyResult: KeyResult
@State var text: String = ""
@FocusState var textIsFocused: Bool
@State var completesKeyResult: Bool = false
var body: some View {
VStack {
Button("Cancel") {
dismiss()
}
Text("Key Result: \(keyResult.text)")
.padding()
Toggle("Goal is Reached?", isOn:$completesKeyResult)
.padding()
TextField(
"Event note",
text: $text
)
.focused($textIsFocused)
.onSubmit {
print("Note: \(text)")
}
.padding()
Button("Record Event") {
print("Recording: \(text) goal is reached? \(completesKeyResult)")
}
.padding()
}
}
}
struct EventEntryView_Previews: PreviewProvider {
static var previews: some View {
if #available(iOS 15.0, *) {
EventEntryView(keyResult: KeyResult.default)
} else {
Text("preview")
}
}
}
This view also works when it's included in other views for preview, it's only not working for this preview.