No video

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

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

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/gah...
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.swiftyp...
👨‍💻 my Core Data and SwiftUI course school.swiftyp...
#swiftdata #coredata #swiftui

Пікірлер: 25
@AndyJMacLeod
@AndyJMacLeod 11 ай бұрын
Great insights and comprehensive evaluation. I think SwiftData is probably going to develop quite quickly over the next couple of years.
@dmitrygolovin8066
@dmitrygolovin8066 Жыл бұрын
Thanks for the great content like always! Keep swift ui videos coming.
@javierdejorgesanchez-garni1158
@javierdejorgesanchez-garni1158 10 ай бұрын
Very useful and informative videos ! Thanks for your content. Maybe one video of how to public data base using iCloudkit.
@sergpryimachuk
@sergpryimachuk Жыл бұрын
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 🤩
@anasahalabi2749
@anasahalabi2749 11 ай бұрын
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
@slmille4
@slmille4 8 ай бұрын
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.
@samurai7938
@samurai7938 11 ай бұрын
The you very much for all your video lessons.
@AndrewDChristie
@AndrewDChristie Ай бұрын
Thanks!
@ShmankyTube
@ShmankyTube Жыл бұрын
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.
@vanylaskywalker
@vanylaskywalker 11 ай бұрын
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?
@alpreller
@alpreller Жыл бұрын
Thank you, please keep doing swiftData, it is the future, could you do inverse relationships and tables please?
@SwiftyPlace
@SwiftyPlace Жыл бұрын
I will keep this in mind! More coming
@burnedoils
@burnedoils 10 ай бұрын
thx u for this neat explanation
@wexcell
@wexcell Жыл бұрын
Does SwiftData support database versioning (migrations)?
@AndyJMacLeod
@AndyJMacLeod 11 ай бұрын
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).
@LivinExtreme
@LivinExtreme Ай бұрын
just learned CoreData wait they are replacing it again!?
@SwiftyPlace
@SwiftyPlace Ай бұрын
They introduced a replacement SwiftData last year. But it is not good. You are much better of with CoreData for now.
@literallyshane4306
@literallyshane4306 Жыл бұрын
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 11 ай бұрын
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.
@yuniorsanchez8578
@yuniorsanchez8578 9 ай бұрын
Did you do this same comparation recently ?
@rompopunyanitya9654
@rompopunyanitya9654 10 ай бұрын
Nice thank u
@w0mblemania
@w0mblemania Жыл бұрын
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.
@EvolvingParty
@EvolvingParty Жыл бұрын
Wait for iOS18 before trying to switch to SwiftData ✅
@Anonymous-sl7jk
@Anonymous-sl7jk 7 ай бұрын
Your content is amazing. I'm afraid you are losing viewers due to light mode :(
@AndrewDChristie
@AndrewDChristie 7 ай бұрын
Thanks!
Is CoreData better without MVVM?
11:03
Flo writes Code
Рет қаралды 1,4 М.
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 10 МЛН
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 8 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 39 МЛН
CloudKit - Intro, Pricing, Terms, & Definitions
17:26
Sean Allen
Рет қаралды 22 М.
Comparing @Observable to ObservableObjects in SwiftUI
12:57
donny wals
Рет қаралды 1,3 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 351 М.
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 43 М.
Фреймворк SwiftData
7:29
SwiftBook
Рет қаралды 3,4 М.
Data Modeling in the Modern Data Stack
10:14
Kahan Data Solutions
Рет қаралды 99 М.
SCRUM vs Kanban vs Waterfall. В чем разница?
22:53
Азат Закуанов
Рет қаралды 36 М.
iOS Core Data QuickStart Tutorial 2020
1:10:58
CodeWithChris
Рет қаралды 101 М.
Son ❤️ #shorts by Leisi Show
00:41
Leisi Show
Рет қаралды 10 МЛН