Periodically I launch my app from Xcode to find Core Data errors due to an empty model file. The versioned model files are found in the main bundle but the model file still inits to nil. See my answer for partial workarounds but no solution to date.
I've verified that the files exist and are accessible using the access function. I've tried using initWithContentsOfURL and mergedModelFromBundles with the same result.
This happens randomly and I suspect something is changing the model file behind the scenes but I don't know what.
Restarting my computer seems to have solved the security related crash but this also necessitates removing the existing Core Data store file as it complains the existing one doesn't match the model file.
[UPDATE]
Restarting does not solve the problem. But reseting the current version of the Core Data model file did the trick. I changed it to an older version and then back. This question helped me think of this as something to try. Using mergedModelFromBundles: and versioning (CoreData) Still not sure what the root problem is.
[ANOTHER UPDATE]
I put a file monitor on the .xccurrentversion file in my Core Data momd file bundle to observe when the file is being touched. I've noticed that XCode (or some build tool) updates the .xccurrentversion file periodically when XCode comes to foreground (either when the project is opened or when it's been in background for a while). When it did this today it updated the file setting _XCCurrentVersionName to the main momd file bundle rather than the version file. I replaced the .xccurrentversion file with an older version and it launched. This would explain why reseting the current model version fixes this issue. I have no idea what the conditions are for XCode to update this file.
Related
I am building an openwrt firmware for an old mt7620 board for commercial purpose (captive portal)
I am encountering a strange behaviour when I try to save updated config files. I am trying to figure out the reason.
This is an example of what happens :
1 – FIRST TRIAL :
I compiled an old Chaos Calmer 15.01 openwrt version. From the console, I go to the /overlay/upper/etc/config:
Before reboot
I modify or delete the existing files in the [..]/etc/config/ folder
I create a new file for example "test" in [..]/etc/config/
I create a folder "new_folder" with a file inside
After reboot:
changes are not kept or deleted files are back in [..]/etc/config/ folder
the new file for example "test" is still there
the "new_folder" with its file inside are still there
Finally :
if I delete the new files "test" and "new_folder", after the reboot they are effectively deleted
So to sum-up : only pre-existing files in [..]/etc/config/ folder are reverted back at each reboot.
2 – SECOND TRIAL :
I compiled a firmware of the same version without UCI, when I modify the files in /etc/config/, changes made manually are kept after reboot, except 'wireless' which revert to its initial state.
It seems like some process involving UCI at startup use the original files and not the edited ones.
I took a look to the .sh scripts in /etc/init.d, /etc/rc.d, lib/config, lib/functions, lib/preinit... to see what is going on but its still not clear when and where config files are processed (even after looking at topics on the subject)
3 – THIRD TRIAL :
I managed to compile another firmware based on LEDE 17.01 to see if there are benefits. Unfortunately, I still have the same problem concerning the files in the /etc/config which always revert to their default value.
4 - FINALLY TO SUM-UP :
Is there a way to turn this behaviour off, or is it a kind of 'file protection' towards something that could be seen as 'currupted' by the system ?
Note :
I know that theses versions are very old and some people may recommend to upgrade it.
But, In regards to my constraints, I tried to update to openwrt versions >= 18.06. Each time I have kernel panics even by compiling with the custom changes I made that work with the previous versions (DTS file).
So, I am stuck with it for instance, I prefer having one problem at a time.
Sorry for the long post.
Thanks a lot, by advance, If someone have an idea or have already seen such a situation.
Best Regards.
Edit : Overlay at boot time
Overlay at boot time
I am trying to write a thumbnail provider extension (on macOS) that accesses the Core Data store of the main application, shared via an app group, to find images to base icon thumbnails on. This worked fine until I added one attribute to the Core Data model. Now the extension always crashes with An error occurred during persistent store migration and attempt to write a readonly database.
Creating a new default model version and deleting the Core Data Store doesn't help. Somehow the thumbnailer extension still thinks that the store written by the main application uses an earlier model, which makes no sense.
If I set shouldMigrateStoreAutomatically to NO, I get The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store.
If I set readOnly = YES on the NSPersistentStoreDescription, I get The file couldn’t be saved because you don’t have permission. which I think may be a concurrency isse, caused by lots of thumbnail provider threads trying to migrate the store all at once.
EDIT: Original code here: https://github.com/angstsmurf/spatterlight/blob/quicklook/SpatterlightThumbnails/ThumbnailProvider.m
Right, I got this to work, but I'm not sure how.
Some of the things I did: cleaned up the build folder, deleted all copies of the main application from my hdd, built a new release version of it, put it in Applications, picked that one when Xcode asked me to choose an app to run after building the thumbnail provider extension. That still didn't work, but afterwards I no longer got any store migration errors when building and running in Xcode.
So basically the problem seems to have been that Xcode picked an old build of the main application to run along with the extension, which created an old version of the Core Data store. Or the old store was still being cached somewhere. Just cleaning the build folder was not enough to fix this.
I don't recall having this problem before I migrated to my Retina MacBook Pro, but since doing so, my projects have insisted on loading in the "old" development location. In years past, before XCode 4, we put all our products in /Development/Products. And, after migrating to the new MacBook Pro, they're going back there again. I can use 4.3 or newer and see the same problem with both, so I'm assuming it's some kind of configurable that's at work here.
Of course, the first thing I did was verify that the Preferences/Locations was set to Build Location = Unique. I confirmed this both in the GUI and by popping open the .plist to check the value of IDEBuildLocationStyle and it was set to Unique.
I tried removing my existing configuration files (everthing in ~/Library/Preferences/ named Xcode) and that succeeded in changing the behavior to putting the output in the build directory of the project itself (really not helpful in my world as I have complex multi-project workspaces). Quitting and checking the settings, they were set for IDEBuildLocationStyle=Unique.
So, I copied the working configuration from another machine I had to this one. Since it too had previously had the /Development/Products destination, but had subsequently been moved to the Unique build style, I expected that to work. It did not. It instead returned the output to /Development/Products.
Thinking it might be something with my Xcode install, I created a new user and built from the same source tree (not a duplicate, not a copy, the exact same files). In this case, the output went to the right place (unique subdirectory of the Derived Products for that user). So, I blew away the ~/Preferences/*Xcode* again and copied in the preferences from the new user. Unfortunately, this took us back to the same behavior that the uninitialized configuration had, which is to say building in the build directory of the project itself.
I restored to my backup configuration files, and now I'm back to working at /Development/Products, but this isn't a good long term solution.
When checking the script output for a test script, I can clearly see that somebody is setting SYMROOT to /Development/Products in the case of the older config, and build in the case of the default configuration file.
Clearly there's something here on this system that's influencing the configuration, but I cannot figure out what it is. Any assistance would be highly appreciated!
Also - When I try to use option-Clean to enable Clean Build Folder, it is never enabled, which makes a certain kind of sense, but I thought it might be another data point.
I tried the solution in Strange behavior of Xcode Build Products Path under Build Locations and that had the same result as deleting the preferences: build products as children of the project directory.
Has anyone else seen such a problem? Have you found a solution?
Well, after a very long time of suffering through this on my laptop, I was finally able to track down the problem.
Inside of:
project.xcworkspace/xcuserdata/<user>.xcuserdatad/
there is a WorkspaceSettings.xcsettings file.
It contained a key BuildLocationStyle, which was set to UseTargetSettings.
Deleting the file and thus resetting this value allowed me to get both the Clean Build Folder... working and to get my project building correctly.
Hopefully this will help somebody else.
Indexing, code completion, & coloring disappear from my projects on a fairly regular basis, usually right after I add a file. And then it returns hours or days later, usually for unknown reasons (I've tried keeping a record but it's pretty random). CMD-clicking on even known terms (like viewDidLoad: or NSLocalizedString) result in a "Symbol Not Found" error.
It happens with Xcode 4.2 (I believe it happened in Xcode 4.0.2, but not as frequent).
I have no build errors, warnings, or static analysis messages.
I've restarted Xcode.
I've tried turning precompile off.
I don't have a case where I've got a circular header file include/import.
It happens if I use gcc, LLVM, CLang (in whatever combo).
It happens if I use iOS 4.3 or 5.0.
I've tried deleting the "derived data.", and even only the Index/ path.
After deletion & re-build I see the .hmap file & .xcindex folder (filled with db.xcodeindexdb* files).
...but I can't get code-completion, symbol detection, or coloring back.
What else can I do? I sincerely appreciate the help.
Have you tried a clean install (sudo /Developer/Library/uninstall-devtools)?
I have exactly the same problem for one particular project. Following workaround works for me: apart from deleting Derived Data , I make an SVN update or revert any file of the project. If the project file itself is changed my Xcode displays wrong target ,so I close the project and re-open it and then indexing starts properly.
The most reliable way I've found to force re-indexing of the project is to change the build settings, specifically 'Run Static Analyzer' - I wish I had a real answer though.
This might seem like a silly response, but have you tried to repair file permissions under disk maintenance?
Your thread is old, but anyway...
Deleting the derived data folder helps me everytime. I have to do it quite regularly, which is very annoying. Your find the path in the xCode-Settings(cmd+,) in the locations-tab.
I just had this issue. What worked for me is clearing the derived data, then closing the project and re-opening it. It didn't reindex until I closed and re-opened the project. The project never compiled fully, so it didn't even have to finish building to work.
Opps: This is the same as: Is there a way to reset the error badges in Netbeans? but I don't know how to mark it as such ...
My version of NetBeans 6.9.1 is currently showing a large number of syntax errors in many files, in many projects.
But, if I look at the errors, they are invalid. For example, one error says that an import is referencing a non-existent file. However, that file exists and has no syntax errors.
More importantly, despite all of the errors, the code compiles cleanly and runs correctly.
My guess is that NetBeans is caching some data (OSGi?) that is out of date or has been corrupted. This has happened before, but in the past it wasn't this bad and it magically cleared itself.
I've tried starting and stopping NetBeans, but that doesn't do it. If, as in the above case, I use NetBeans to resave the imported file, it goes away after a minute, but for large projects this is very time-consuming. (Note that I am using jVi, and saving with that embedded editor doesn't not fix the problem, it has to be the NetBeans save command).
I'd really like to find a simple way just to force the whole internal state to refresh itself. Does anybody have any ideas?
To clear this error you need to shut netbeans, go to the .netbeans folder in your home directory C:\users\.netbeans for Win 7,
in there you will see a folder for the version you are using.
in there is a folder called var
delete this folder then re-run netbeans.
This clears the cache in Netbeans allowing it to re scan the folders correctly.
I found a useful plugin you can use called Cache Eraser.