I did create Share Extension. Using this extension I am trying to insert new item to CoreData. The code is below. Variables context and document is created. context.save() not failing. Insertion to the CoreData using main/host app works fine and presented to UI.
Another thing what I noticed that all insertions from Share Extension are stored somewhere else, but not in the main app. It looks that these items are not merged to the main CoreData.
Why my items insertion to CoreData throw Share Extension is not merged to main CoreData?
let context = CoreDataStackManager.sharedManager.persistentContainer.viewContext
let document = SGDocument(context: context)
document.name = "Document Name"
do {
try context.save()
} catch {
fatalError("Unresolved error \(error)")
}
PS: Here is similar question, but without answer.