I receive the following error in terminal in my macOS and iOS targets that crashes a universal app written entirely in swiftUI.
[General] -[NSAlert runModal] may not be invoked inside of transaction begin/commit pair, or inside of transaction commit (usually this means it was invoked inside of a view's -drawRect: method.)
App structure is Sidebar Menu + Master List + Details using Core Data for persistence and Cloudkit NSPersistentCloudKitContainer
for backup / mirroring.
There seems to be a lot of activity prior to the crash relating to IMKInputSession CFRunLoopObserver
.
The crash seems to be associated with a Picker
view within the detail view and whether it is "First Responder" at the time another item in the list is selected or a new item is added to the list (from the toolbar).
Apple has suggested that...
It seems that the app is presenting an alert in response to SwiftUI updating views. That use of -presentError: should be deferred outside of that immediate update (e.g. adding an observer block to the main run loop to present it on the next turn)
... however I have no alerts in the views that crash.
Has anyone else experienced this and if so do you have any suggestions on what worked for you?