I am new to swiftui so i was wondering how to share data that we store in coreData to widget in ios 14
You'll want to use a group container. The widget and main app can share the same database files with Core Data.
Depending on how complex your model is, and on how static your widget UI is, you might want to go through the extra steps edorphy discusses to mirror out a simplified and stripped down model for the widget. This can get complicated and rigid, so I'm not sure I'd recommend it as approach #1. You can also have a denormalized simplified entity in the database itself. That'll be easier to maintain.
If you get to the point where you're instrumenting each I/O, and counting the 4KB, then a more static view archive can be helpful to accelerate launch time.
Depending on how complex your model is, and on how static your widget UI is, you might want to go through the extra steps edorphy discusses to mirror out a simplified and stripped down model for the widget. This can get complicated and rigid, so I'm not sure I'd recommend it as approach #1. You can also have a denormalized simplified entity in the database itself. That'll be easier to maintain.
If you get to the point where you're instrumenting each I/O, and counting the 4KB, then a more static view archive can be helpful to accelerate launch time.