Restarting my macbook resolved the issue.
Post
Replies
Boosts
Views
Activity
I had the same issue and used git status to check the modified files and found a file that was not expected to be modified:
modified: <PROJECT_NAME>.xcworkspace/xcuserdata/tonyayoub.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
I checked out this file to undo any changes and this resolved my issue:
git checkout <PROJECT_NAME>.xcworkspace/xcuserdata/tonyayoub.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
That's why deleting the whole xcuserdata folder as others suggest also resolves the issue.
Setting the launch screen resolved my issue. This looks completely unrelated but it solves the issue.
Thank you @ chrisl7777777
Another way to do that is to pass the context from the view to the ObservableObject whenever needed (with every function call). This will make you easily create unit tests for the view model (the observable object) by testing its functions using a mock context.
OK, moving the property from the ObservedObject to become a private view @State variable solves the issue. But, it was an @Publisehd inside an ObservedObject for a reason (being calculated from other conditions for example). So, no more @Published calculated properties?
This code was producing the same warning:
struct AreaMap: View {
@Binding var region: MKCoordinateRegion
var body: some View {
Map(coordinateRegion: $region)
}
}
Where region was passed in the initializer of AreaMap from its parent view.
This resolved the issue:
struct AreaMap: View {
@Binding var region: MKCoordinateRegion
var body: some View {
let binding = Binding(
get: { self.region },
set: { newValue in
DispatchQueue.main.async {
self.region = newValue
}
}
)
return Map(coordinateRegion: binding)
}
}