-
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
Set higher version .xcdatamodeld file as current #341
Conversation
To set higher version core data model as current
Thanks @rohitpal440. You will probably need to apply the same logic here as well, as all the groups are sorted again before generation https://github.com/rohitpal440/XcodeGen/blob/b0fa7a2845213aeeaa4caf07ad30eb060bfdf00c/Sources/XcodeGenKit/PBXProjGenerator.swift |
Yes, specifically this line https://github.com/rohitpal440/XcodeGen/blob/b0fa7a2845213aeeaa4caf07ad30eb060bfdf00c/Sources/XcodeGenKit/PBXProjGenerator.swift#L291 |
@@ -119,7 +119,7 @@ class SourceGenerator { | |||
let models = (try? path.children()) ?? [] | |||
let modelFileReference = models | |||
.filter { $0.extension == "xcdatamodel" } | |||
.sorted() | |||
.sorted { $0.string.localizedStandardCompare($1.string) == .orderedDescending } |
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.
Even though this will be rewritten in sortGroups
shouldn't this be .orderedAscending
?
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.
Then I've to do something like this currentVersion: modelFileReference.last?.reference
over here https://github.com/rohitpal440/XcodeGen/blob/4d964c07861cd524801b85d4edf611c77e1d2c3b/Sources/XcodeGenKit/SourceGenerator.swift#L134
to make higher version of .xcdatamodel
file as current
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.
Yeah, if they are sorted alphabetically then it should use the last one 👍
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.
So what do you suggest me to do?
- Keep the code as in this PR
OR - Compare using
.orderedAscending
and update the code for getting currentVersion tocurrentVersion: modelFileReference.last?.reference
In both ways I'm going to get the same result, chose approach 1 since the change stays in one place instead of 2.
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.
I'd go with option 2. As you want to sort in ascending order
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.
Fantastic, thank you so much @rohitpal440!
Sort .xcdatamodeld files in decreasing order to set higher version core data model as current.
Current sorting of file takes place as:
after this change sorting will be like
and First element will be set as current core data model