import SwiftUI
import Perception
@Perceptible
class HelloModel {
var msg: String = "Hello, World"
}
struct HelloView: View {
@Environment(HelloModel.self) var model
var body: some View {
WithPerceptionTracking {
Text(model.msg)
}
}
}
#Preview {
HelloView()
.environment(HelloModel())
}
== PAUSED REASON:
processCrashed
== PREVIEW UPDATE ERROR:
CrashReportError: Fatal Error in Environment.swift
fito crashed due to fatalError in Environment.swift at line 54.
No perceptible object of type HelloModel found. A View.environment(_:) for HelloModel may be missing as an ancestor of this view.
Description
Here is my code:
It crashes in preview:
Checklist
@Observablemacro or another tool from theObservationframework, please file it directly with Apple.mainbranch of this package.Expected behavior
No crash happened
Actual behavior
Crash happened
Steps to reproduce
Described in description
Perception version information
1.4.1
Destination operating system
iOS 16.0
Xcode version information
Version 16.1 (16B40)
Swift Compiler version information
No response