I converted a Core Data to SwiftData: Here is what happened - Xcode 15 Beta 5

  Рет қаралды 7,134

Karin Prater

Karin Prater

Күн бұрын

Core Data and SwiftData are both frameworks that help you store the user's data in a SwiftUI application. In this video, I share my experience of converting a complex Core Data project to SwiftData. I discuss the advantages, missing features, and issues I encountered during the process.
I aim to provide a comprehensive comparison between Core Data and SwiftData, showcasing the similarities and differences between the two frameworks. By the end of the video, you will have a good understanding of what it’s like to work with SwiftData and be able to make an informed decision about whether to migrate an existing Core Data project or start a new app with SwiftData.
I begin by explaining what SwiftData is and clarifying that it is not built on top of Core Data but is a separate framework specifically designed for Swift and SwiftUI applications. I highlight the advantages of using SwiftData, such as working with native Swift types and SwiftUI, as well as the ease of transferring learnings from Core Data to SwiftData.
Throughout the video, I compare the tools and concepts used in Core Data and SwiftData, such as persistent containers, managed object models, predicates, and macros. I discuss the convenience of writing filters in Swift code instead of using strings and the promise of type safety.
I delve into the challenges and limitations I encountered while working with SwiftData. I touch on issues with relationships, enums, optionals, and sorting. I explain how queries and fetching data can be problematic, particularly in terms of dynamically changing predicates and sorting. SwiftData does not offer section queries and does not support UIKit with an equivalent of NSFetchedResultsController.
I touch on the difficulties of implementing MVVM architecture with SwiftData and the limitations of querying and previewing data.
I acknowledge the positive aspects of SwiftData, such as its integration with the new observation framework, which enables more efficient data flow. I talk about the support for Swift concurrency and the convenience of auto-saving data in SwiftData.
In conclusion, I express my personal opinion that SwiftData is not yet ready for production use. I believe there are still too many bugs, missing features, and limitations that need to be addressed. I recommend sticking with Core Data, a proven framework with extensive documentation and resources, unless there is a significant improvement in SwiftData.
I am using macOS Ventura 13.4 and Xcode 15 beta 5
⬇️ Github project github.com/gahntpo/SwiftDataT...
overview
00:00 Introduction
01:00 What is SwiftData and how is it different to CoreData
04:33 Model definition in SwiftData and limitations
07:30 @Query and dynamic updates
14:52 Predicate marco problems for advanced filtering
16:25 SwiftData with Observation feature for improved data flow and performance
19:04 SwiftData and Xcode previews ??!
22:50 Auto save
23:26 More missing features and problems
25:41 Wrap up and my personal recommendation of SwiftData vs CoreData
If you liked what you learned and you want to see more, check out one of my courses!
👨‍💻 my SwiftUI course school.swiftyplace.com/course...
👨‍💻 my Core Data and SwiftUI course school.swiftyplace.com/course...
#swiftdata #coredata #swiftui

Пікірлер: 24
@dmitrygolovin8066
@dmitrygolovin8066 10 ай бұрын
Thanks for the great content like always! Keep swift ui videos coming.
@AndyJMacLeod
@AndyJMacLeod 9 ай бұрын
Great insights and comprehensive evaluation. I think SwiftData is probably going to develop quite quickly over the next couple of years.
@samurai7938
@samurai7938 10 ай бұрын
The you very much for all your video lessons.
@burnedoils
@burnedoils 8 ай бұрын
thx u for this neat explanation
@anasahalabi2749
@anasahalabi2749 9 ай бұрын
I saw you on Instagram, your content is amazing, thank you for sharing this stuff, please keep up the amazing job, also please consider changing to dark mode on xcode because it feels more comfy
@sergpryimachuk
@sergpryimachuk 10 ай бұрын
I bought a book about CoreData and started a project with it just a few weeks before WWDC, so I stick with CoreData to return investment 😅 But a glance look at SwiftData makes me excited about it 🤩
@javierdejorgesanchez-garni1158
@javierdejorgesanchez-garni1158 8 ай бұрын
Very useful and informative videos ! Thanks for your content. Maybe one video of how to public data base using iCloudkit.
@AndrewDChristie
@AndrewDChristie 5 ай бұрын
Thanks!
@rompopunyanitya9654
@rompopunyanitya9654 9 ай бұрын
Nice thank u
@vanylaskywalker
@vanylaskywalker 10 ай бұрын
Should we still use codable structs to decode JSON API responses or should we use the new codable @Model class to decode API responses? Which is better?
@literallyshane4306
@literallyshane4306 10 ай бұрын
Thank you for another great video Karin. I am trying to integrate Swiftdata into my network code, converting a HTTP JSON response but having issues with my JSONdecoder. I haven't seen any examples of people using swift data outside of SwiftUI files. Have you any thoughts or advice on this?
@vanylaskywalker
@vanylaskywalker 10 ай бұрын
I have tried to use SwiftData @Model class to decode JSON and it worked without problem. I am not sure it is the recommended way, or should we stick to structs like before.
@ShmankyTube
@ShmankyTube 10 ай бұрын
As you said around 18:30, I am curious to know if you can abstract away SwiftData so that your views don't know anything about SwiftData. With Core Data, I like to make a separate Swift Package and everything working with Core Data goes in there, even though SwiftUI has conveniences like @FetchRequest.
@alpreller
@alpreller 10 ай бұрын
Thank you, please keep doing swiftData, it is the future, could you do inverse relationships and tables please?
@SwiftyPlace
@SwiftyPlace 10 ай бұрын
I will keep this in mind! More coming
@wexcell
@wexcell 10 ай бұрын
Does SwiftData support database versioning (migrations)?
@yuniorsanchez8578
@yuniorsanchez8578 7 ай бұрын
Did you do this same comparation recently ?
@slmille4
@slmille4 6 ай бұрын
Even after a few months of bug fixes it still seems like SwiftData is meant to be for small projects where Core Data is overkill. For example there doesn't seem to be a general way to move changes from the view context to a background context and back to handle synchronization. Core Data is more scalable so there not much reason for anyone who already understands how to use Core Data with SwiftUI to switch.
@LivinExtreme
@LivinExtreme 6 күн бұрын
just learned CoreData wait they are replacing it again!?
@SwiftyPlace
@SwiftyPlace 4 күн бұрын
They introduced a replacement SwiftData last year. But it is not good. You are much better of with CoreData for now.
@EvolvingParty
@EvolvingParty 10 ай бұрын
Wait for iOS18 before trying to switch to SwiftData ✅
@w0mblemania
@w0mblemania 10 ай бұрын
Thanks for this. This is very disappointing. It feels that, once again, it was pushed out according to the WWDC and iOS 17 marketing schedule. I think it's untenable to target iOS 17.0 at this stage. It's just not going to be ready in time. OTOH, I just hate the idea of having to use Core Data for a new app. Aaaaargh.
@AndyJMacLeod
@AndyJMacLeod 9 ай бұрын
I’m developing my first app using SwiftUI and SwiftData. I don’t have to support earlier versions of iOS and I’m expecting my app will grow over the next few years. So the fact that SwiftData has teething problems is not a dealbreaker for me. I like the new observation framework, and I’d say that SwiftData is probably more user-friendly. But, the lack of documentation and tutorials is a struggle for newer developers. (Telling the difference between bad code and a broken feature is somewhat challenging).
@Anonymous-sl7jk
@Anonymous-sl7jk 5 ай бұрын
Your content is amazing. I'm afraid you are losing viewers due to light mode :(
⬅️🤔➡️
00:31
Celine Dept
Рет қаралды 50 МЛН
МАМА И STANDOFF 2 😳 !FAKE GUN! #shorts
00:34
INNA SERG
Рет қаралды 3,7 МЛН
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 5 МЛН
Is CoreData better without MVVM?
11:03
Flo writes Code
Рет қаралды 1,3 М.
Donny Wals: Using Core Data in a Modern SwiftUI Application
41:18
Swift Heroes
Рет қаралды 13 М.
The Last SwiftData Tutorial You Will Ever Need
1:09:25
Rebeloper - Rebel Developer
Рет қаралды 4,9 М.
8. SwiftData   CloudKit
18:20
Stewart Lynch
Рет қаралды 5 М.
How to use Enums in Swift | Swift Basics #10
15:01
Swiftful Thinking
Рет қаралды 8 М.