UPDATE: Issue seems to be related to a view initializer and not to creating the Habit object. The view is part of the home view which is displayed immediately and this is what was causing the crash. I was able to get a version of the app to work with a simple ListView and no initializer and am now proceeding to add back the initializer one step at a time to find out what is the culprit. But again this issue never occurs in a build directly from Xcode so I need to add each new build to TestFlight to see if there is a problem. Wish I could get some Apple help on this...
Seems like it does not like any Predicate in the initializer. Even this simple initializer causes a crash (but not when I use the Xcode build).
init(navigationPath: Binding<NavigationPath>, searchString: String = "", sortOrder: [SortDescriptor<Habit>] = []) {
_habits = Query(filter: #Predicate { habit in
if searchString.isEmpty {
true
} else {
habit.title.localizedStandardContains(searchString) ||
habit.detail.localizedStandardContains(searchString)
}
}, sort: sortOrder)
self._navigationPath = navigationPath
}