Hello
I noticed that in my app, when I add data (I am using Core Data) the size of the app increases, as expected, the problem occurs when I delete data, the size of the app remains unchanged and sometimes increases, I thought there was an error in the my code and so I created, from scratch, a project for iOS with SwiftUI and Core Data enabled (the default template that Xcode provides) and also with the SwiftUI & Core Data default app the same problem happens.
Is there a way to fix it or is there an explanation for this?
Thank you!
short answer: don't worry about it. Apple has invested heavily in CoreData and uses it extensively. wrt deleted records, Core Data will clean up its storage over time.
longer answer: to understand what's going on, you'll have to dive into the architecture and implementation of structured database systems, and specifically how SQLite (which is used by default by Core Data) organizes data and indices into its file structures. For some insights, see here https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreData/PersistentStoreFeatures.html