Conversation

Fahim Farook

In Xcode 15 beta, when you create a new project, you now can select storage options and can switch between SwiftData and Core Data 🙂

#Apple #WWDC2023 #SwiftData #Beta
New project options dialog in X…
1
0
0

@f did you already find an easy way to migrate from Core Data to SwiftData?

1
0
0
@_holger I generally don’t use CoreData 🙂 I use my own library which uses SQLite as the local storage and CloudKit as the remote storage. It works kind of like a very lightweight ORM. (Repo here: https://github.com/FahimF/SQLiteDB)

Since most of my code simply uses classes which represent the SQLite tables as models, switching to SwiftData should be fairly painless. Of course, converting existing data is going to be the hard part since I’m assuming I’m going to have to do that manually … as in read the data from SQLite and then save as SwiftData in the new version of the app before switching over to SwiftData.

But honestly, no idea of all the implications at this point since I just got Xcode 15 beta working and am just about to try doing some stuff with SwiftData 😛
1
0
1

@f ah understood. I‘m using only CloudKit (with CoreData as local storage). I’m curious if Apple will provide an easy way to switch to SwiftData. Sure, manually copying should be a possibility.

1
0
0
@_holger It might depend, at least to an extent, on what the underlying storage format for SwiftData is? Is it still SQLite? Or something else entirely?

I’m curious and this is something I wanted to dig into once I got a quick SwiftData project going. But haven’t gotten that far yet — so many shiny new things to look at in the Xcode beta 😛
1
0
1

@f i believe they said it’s a layer on top of core data. So it should still be SQLite. My main concern would be the definition of the Objects/Entities that are currently done in a dedicated file in Xcode.

1
0
1
@_holger Apparently, it’s possible for Core Data and SwiftData to co-exist in the same app … Plus, the same sample also talks about converting from Core Data to SwiftData.

Sample code here:

https://developer.apple.com/documentation/coredata/adopting_swiftdata_for_a_core_data_app
1
0
1

@f oh Great. Thanks a lot. \o/

1
0
0
@_holger Sure thing 🙂 I’m sure it will be covered in the SwiftData sessions from either yesterday or today but figured you’d like to know since that should set your mind at ease …
1
0
0

@f I appreciate that. I‘m currently very busy with our baby and her first visit to my parents in law and was only able to watch keynote and State of the Union. I guess in 2 weeks I will have time to dig into the sessions myself.

1
0
0
@_holger A new baby is a blessing but I know that as a parent you’ll have very little time. Congratulations on the baby, by the way 🙂

I actually haven’t had the time to watch the videos from yesterday still either but will send links your way if I find a session that is relevant to the discussion, and hopefully, you can catch up later at your leisure …
2
0
1

@f thanks. She just turned 1 year old and we are visiting her grandparents who live 8000km away from our home for the first time. 😃

1
0
0
@_holger Enjoy your time with your daughter and in-laws 🙂 They grow up so fast — not that we have any children, but I used to spend all my time with my nephews and but once they get to be about 10 years old, they have no time for you since they have other concerns 😀
0
0
1
@_holger Just saw this WWDC video:
https://developer.apple.com/videos/play/wwdc2023-10189

I think that covers everything about how to migrate from a Core Data project to SwiftData and how to co-exist with a Core Data project. So probably the one you need (to watch, I mean) 🙂
1
0
1

@f thanks a lot. you are doing me such a great favour. Can't thank you enough.

1
0
0
@_holger You’re welcome 🙂 Only way forward is to help each other out.
0
0
1