SwiftData: externalStorage attribute on ios18

Hello,

I'm experiencing an issue with iOS 18 Beta 3 and SwiftData.

I have a model with some attributes marked as externalStorage because they are pretty large. In iOS 17 I could display a list of all my Models and it would not prefetch the externalStorage attributes. Now in iOS 18 it seems the attributes are fetched even though I don't use them in my list. It's an issue because the memory use of my app goes from 100mo on iOS 17 to more than 1gb on iOS 18 because of this. My app is configured to sync with iCloud.

Anyone else experiencing the issue?

Thanks

Gil

Answered by jhokit in 799160022

@Gil see https://developer.apple.com/forums/thread/761522?page=1#799145022

I was asked by an Apple contact to write this up and cross link to Feedback Assistant. Hopefully we can find a workaround.

Yes, same here.

Related bug, calling .count on a Query's array seems to load all models, including the large items in external storage, causing a memory overflow. Calling .count on iOS 17 is fast and inexpensive.

  • Jeff

Reported as FB14323934

Accepted Answer

@Gil see https://developer.apple.com/forums/thread/761522?page=1#799145022

I was asked by an Apple contact to write this up and cross link to Feedback Assistant. Hopefully we can find a workaround.

SwiftData: externalStorage attribute on ios18
 
 
Q