Xcode Core Data models are missing - xcode

I am working on an iOS app using Core Data, and after doing some stuff in the storyboard, I tried to run the app and realize that all of my Core Data models are missing except my original one. My playground is also missing, but I don't really care about that. I have no idea what happened, and really need to get those data models back. This is what I see when I look for them in the project navigator.
When I try to build the app, it builds fine, but then I immediatly get this error:
016-02-12 11:46:22.779 App Name[51990:1666336] CoreData: Failed to load NSManagedObjectModel with URL
'file:///Users/myname/Library/Developer/CoreSimulator/Devices/EC2BDB71-BE0C-46CB-B208-09C5D0FD2F3B/data/Containers/Bundle/Application/76FAF1C3-8F85-4A1A-81DE-309B984176E1/App%20Name.app/DataModel.momd/'
fatal error: unexpectedly found nil while unwrapping an Optional value
I tried undoing all my changes I made in git since the last commit, but it still can't find them. What could have happened? Is there any way I can get them back?

It's hard to say exactly what happened, but something is causing your files to disappear. It's not in any way related to Core Data or Swift playgrounds-- you've got a serious problem somewhere and it's making you lose data.
These files should be in your git repository. If you can't find them by undoing changes since your last commit, you need to dig deeper. If they were ever committed, they're recoverable, but going back to the last commit may not be enough. They should also exist in whatever system you use to back up your hard drive.
Core Data may be able to help you recover the models by other means. If you have an older compiled copy of the app somewhere, it will contain compiled versions of the data model files. Xcode can import those and re-create the old model files. You'd do this by creating a new model file, then going to the "Edit" menu and selecting "Import...".
But, all this is secondary to your real problem, which is that you're losing files and you don't know why. You could lose more files in the future. Whatever happened could happen again. You need to figure out why you're losing files and fix that problem.

Related

I have a bunch of files in my stage area which is causing issues and I don't know how to remove them

I was working on a static website and decided to change my account as I recently changed my Github username. When I say account, I mean the icon in the bottom left corner of VS Code. In doing so, 10k files were added, and all my extensions disappeared.
The staged files include App Data files that I can't clear.
My Discord is affected. I can't open it as when I do, a message comes up and says:
'update.exe' has been moved or changed. Would you like to delete the shortcut?
Although it's an issue, I essentially have to reinstall it, but the same issue may still arise, which it has as I've tried reinstalling it.
My concern is I feel I may affect other programs by trying to come up with a solution.
I'm posting this question to get help on removing the 10k files that are staged and do not affect program files/app data. When I try to commit these files, I get an error saying,
Git Fatal :pathsepc C\Users.....\getconfig did not match any files
I would think all I need to do is add these files to a gitignore file, but I would need steps if so.
I hope I've explained my problem clearly to get a solution.
Please help.
Staged files

Why aren't my nib files being created?

I've inherited a objective c application that I don't know much about.
My task was to change the login from a normal form view type thing, to a web view that gets content from a server. This all went fine and is implemented, but things weren't working right in the localized version.
Since there are no strings used, I deleted the localized files and now it seems my nib files don't get created. It's like there is a compiler error that's not reported. I checked the resource files in the build area, and it doesn't create nib files for anything after the login view I changed.
No errors are being reported during the build. I've tried re-starting Xcode, changing the branch in git to something without these changes. Nothing seems to clear up the issue.
For anyone else that comes across something like this. What finally worked for me was completely re-cloning the project from git. It appears that some of the files in the project were not tracked and just stayed around when I changed branches. I'm not sure if this is config related file, which we commonly don't track. All I know is that re-cloning fixed the issue.
In researching the problem, other common fixes include deleting and recreating offending xib files. Simply restarting Xcode. And, deleting a variety of other project related files and directories.
Hope this helps someone.

Problems Using Snapshots in Xcode 5 Mac

A couple of people have asked a similar question, the last one a year ago, with no solution (Here and here), so I thought I'd try it again.
I've created snapshots in Xcode 5.1 on a few occasions before making significant code changes. When I go to restore them, I've seen a couple of different behaviors:
There's one file that changed. Xcode shows me the before and after diffs, and I say OK, and click on Restore. The result, nothing's changed.
Same as one, except in this case there are multiple files that have changed. It shows me one, and it looks good. So I click Restore. It doesn't show me any of the other files diffs that have changed, and it doesn't prompt me to be sure I don't want to look at them. After the fact, I've surmised that I need to click on each changed files in order to accept the changes. But still, there's only one Restore button, which dismissed the window. In any case, none of the files have been restored to their former state. If I try to restore from that same snapshot again (naively thinking I could try to retrieve the other changed files), it tells me that the current state and the snapshot are the same.
If I export the changes to another directory, then I do get the reverted files. It's when I do a File->Restore Snapshot where I get no results.
I've taken to manually creating zip archives of the source so I can recover the files manually.
I don't have any Source Control in use in Xcode so far. It seems I should do that if only to do periodic commits on my own.
Do other people use snapshots successfully? Has anyone else experienced this behavior in Xcode 5?
Thanks much for your help. I've yet to get any response on the Apple Developers Forum on the topic :(
-Eric

XCode 4.2 Source Control problems

I seem to have a major problem. I opened up Xcode and my main view controller code seems to have been replaced with the original code, it's all gone. All my other files have the little 'M' for modified icon next to them, this problem file however does not. It seems like it's gone back to the original version.
Now, Can I go back to my modified version, or is it all gone? This is a for a test app so although not crucial, I'd really prefer to not lose it all :)
Thanks
Just putting an answer here as I hate to leave things with no answers. Dropbox sorted my problem as I had a backup copy of everything, and I am yet to find out what went wrong. I'm now using a combination of Dropbox and a GIT repo to keeps things save.

Xcode not predicting

Am new to objective-c and xcode, and i love programming with them. But am facing a problem with xcode this has occurred quite a few times before, i.e the xcode's Auto-Suggestion mode is not working.
By Auto-Suggestion i mean- when i type say two letters 'UI..' xcode predicts the remaining word to be "UIColor, UIButton, .. etc".
Same for the instance methods eg. you type 'init ' and a list is shown as "initWithFrame,
initWithNibName, .." and so on, which makes coding so easy.
But after i performed some operation like undo or delete i don't remember what i did exactly, this auto-prediction is not working and this is happening only on a particular file.
Any idea what i did wrong to make this happen?
Thanks
Xcode sometimes freaks out and exhibits this behavior. Best you can do in this case is clean your project (cmd-shift-K), close Xcode, then re-open it.
I have noticed this behavior especially when using #defined macros extensively.
I know this post is old, but the correct way to resolve this issue is to clear your derived data. After cleaning the derived data and restarting Xcode, your project will say "Indexing" which is the process of setting up everything required to make this feature work. After that, everything should work again.
To clear derived data go to Xcode->Preferences. Then click the little arrow next to the path to the derived data folder. Finder will open with the projects in derived data. Simply select and delete the one specific to your project giving the issue (Don't worry, this will not affect your project).
If there are any compile errors, then also prediction doesn't work properly. try resolving them first.

Resources