-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to determining the current version of a versioned CoreData model #364
Conversation
4ea5f97
to
e7f02d4
Compare
…o determine its current active version
e7f02d4
to
9831711
Compare
One thing to note is that the alphabetical order implementation here will break even for very basic use cases. A very simple versioned model could look like this
When applying the existing sort logic and taking the last item as the current CoreData model you will end up with
And Model.xcdatamodel incorrectly set as the current version. I'd suggest we should just remove the alphabetical fallback completely but I can't be certain that all CoreData models do include a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rpassis, looks great!
fileReferencesByPath[fileReferenceKey] = versionGroup | ||
return versionGroup | ||
} else { | ||
guard path.extension == "xcdatamodeld" else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the if
as opposed to the guard
? Not being a xcdatamodeld
is not a failing case, and we may handle other filetypes differently in the future as well.
Additionally it will make these diffs easier to read.
@yonaskolb thanks for the feedback! I've addressed your comment and pushed a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rpassis!
The current implementation for generating versioned CoreData models and selecting the current active version uses alphabetical sorting. This can work for most simple projects but is likely to break for less conventional setups.
A better solution is to parse the
.xccurrentversion
file which is included inside the CoreData versioned model. This file is in plist format and is created automatically by Xcode.This is a fix for issue #362