I have solved the problem but I would like to understand why it occurs
Using xCode Version 14.0.1 (14A400)
For iPhone Pro 14 Ios16 simulation with the following ContentView coding
@EnvironmentObject var objectPickVM: ObjectPickViewModel
... NavigationLink(destination:
PickSavedObjectView()
// .environmentObject(objectPickVM)
// .environmentObject(coreDataVM)
, isActive: self.$isActive ) {
Text("Saved equipment")
.font(isActive ? .headline:.body)
}
compiles and runs without any problem.
However for an iPad mini (6th generation) ios16 simulation unless I activate
.environmentObject(objectPickVM)
.environmentObject(coreDataVM)
the compiler crashes with "Fatal error: No ObservableObject of type ObjectPickViewModel found. A View.environmentObject(_:) for ObjectPickViewModel may be missing as an ancestor of this view."
As a novice coder I may well have made an error in my implementation of @StateObject, @Published and .environmentObject(), but I cannot understand why the iPhone does not require the added coding but the iPad simulation does. There is no device type related code in my programme.
Is there a distinction between how iPhone and iPad implement NavigationLink?
Could someone direct me to any discussion of this as I attempted but could not find it.