-
Notifications
You must be signed in to change notification settings - Fork 458
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
CoreData Model version is incorrectly set/overridden (xcdatamodeld) #81
Comments
Yeah, assuming the last version is the correct version is not always going to be correct. Looking at the code, it’s also not being explicitly sorted, so there is also a chance of the FS not returning them in the expected order. Is this something you will want to create a patch for? |
I don't want to discourage anyone else from patching it, but I'll give it a shot. |
Indeed a bug. Ouch! Sent from my iPhone
|
@Ashton-W Don’t worry about it. A patch is much appreciated, so we’ll definitely spend some time reviewing it and providing feedback. |
Request for comments Ashton-W@8c77d9a I'm still learning how to run/write the tests, and I haven't worked out how to build a local version of cocoapods. Any tips on that appreciated aswell. |
To run the xcodeproj tests, from the checkout run:
|
I’m assuming you want to run CocoaPods with these Xcodeproj changes applied? Because the way to do that is different than running CocoaPods itself from HEAD. In this case it’s probably simplest to just install the gem built form the repo:
Or if you need sudo to be able to install gems:
|
Here’s more information on running CocoaPods itself from a local path, but also using the latest local xcodeproj needs more tweaking, so if it’s really just about these Xcodeproj modifcations, just install the gem like I mentioned in the previous message. |
Thanks for the great feedback and tips @alloy! Request for comments Ashton-W@b724b23 |
Looks good! You can take inspiration for the test from here and add it next to that test. To stub the plist, do something like the following: Xcodeproj.stubs(:read_plist).with('expected/path').returns({ '_XCCurrentVersionName' => 'expected name' }) |
Request for comments Ashton-W@698e527 Ashton-W@8047884 I have fixed some errors and added a basic test. Next I'll confirm it is working in CocoaPods. |
So far I have not been able to fix this issue. I think the cause of this problem may be somewhere other than I'll keep looking into it. |
With a podspec like this: s.resources = ['CoreDataPodSample/Classes/*.xcdatamodeld'] and your source xcode project having a xcdatamodeld/.xccurrentversion file like this: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>CoreDataPodSample 2.xcdatamodel</string>
</dict>
</plist> CocoaPods still generates this: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
Unless I am adding the xcdatamodeld to the podspec incorrectly - I have found no examples or documentation for that. Edit: Actually the xccurrentversion file is overwritten by Xcode when it loads the Pods project if the project |
Ok this has turned out to be a bit more complex than first though. It seems this note from the original CocoaPods issue is the problem
The .xcdatamodeld shows up like that because it has no children nodes, I have been testing a few different podspecs and none so far have resulted in creating the children nodes correctly. So Xcode opens the project and fixes this problem by stripping the Maybe we should revert the recent changes to this until we come up with a working solution? @alloy |
Was a bit busy today. I’ll probably have some time on Sunday to read-up on this. |
From the specs I have written every things seems to be working on the Xcodeproj side, the current version is read from the .xccurrentversion plist, or the last .xcdatamodel file processed if there is no .xccurrentversion file. I am unable to find where CocoaPods is handling .xcdatamodeld incorrectly, it may have something to do with it being a 'package', not a file. |
@Ashton-W Can you open a pull request? Moreover can you point out a pod which is not working properly? |
I don't know of a pod in the main repo using versioned CoreData models. This has come up in pods I use privately at my company. I have however mocked up a repo for testing: https://github.com/Ashton-W/CoreDataPodSample |
Ugh, sorry for dropping the ball on this. Thanks for the follow-up, @irrationalfab! |
@Ashton-W I have merged your pull and credited you in the changelogs. The issue was related to the fact that Xcodeproj had an approximative handling of the paths, which needed some love. As CocoaPods in the, implementation of the last version, was passing relative paths, Xcodeproj would attempt to read the paths from the working directory. This has been fixed now. |
@Ashton-W Thanks btw! |
Thank you 👍 |
Great 👍 |
From CocoaPods/CocoaPods#1288
I think the new
xcdatamodeld
support has a bug in how it sets the model version. As it does not keep the version set by xcode originally, and kept in the.xccurrentversion
plist file inside thexcdatamodeld/
.64cbdfd#L0R226
The code contains the comment
I don't think that is the correct behaviour if a version has been set already.
The text was updated successfully, but these errors were encountered: