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