-2

would anybody be so kind to provide a link or "steps to follow" that need to be done when you change a model and you want the updated app releases not to crash?

Whenever I make a change to the model, I need to reinstall the app. If I don't the app crashes whenever it tries to access the "new value" from the model changed.

Thank you.

2
  • The word you’re looking for is migration if you need to search for more information but start with SwiftData By Example that has some good information about this topic Commented Jul 16, 2024 at 12:13
  • thx, I will check it out. Libor Commented Jul 16, 2024 at 15:28

1 Answer 1

1

Some simple changes like adding or removing a property are handled automatically (lightweight migration).

When you rename a property or relationship you can use this:

@Attribute(originalName: "name")
let firstName: String // Renamed from "name" to "firstName".

For more advanced migrations there's "complex migration".

Source and more information: https://developer.apple.com/videos/play/wwdc2023/10195/?time=330

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.