Xcode modifies current CoreData model version at every launch - ios

I'm using Xcode 4.6 to work on a project which uses CoreData. The data model is now at version 13 and uses lightweight migration.
My problem: At every launch Xcode seems to modify the PROJECT.xcdatamodeld/.xccurrentversion file to be set to version 1. I noticed that the modified file is automatically added to the GIT index. The changes made to this file are NOT reflected by the GUI of Xcode which tells me that my model's current version is 13. This problem started at some point during the development process (maybe at model version 7) and persists even for new model versions. The strange thing about it that even different Xcode installations on different computers show this behavior for this project. I included a screenshot of the changes made to the file.
My workaround is to reset the changes to this file at every launch of Xcode using GIT but it's very annoying. Someone got an idea how to solve this? Seems like a bug in Xcode.

Solved: The problem was an old entry in the project.pbxproj file (Open PROJECT.xcodeproj with right click -> "Show package content"). I deleted the section as shown in my screenshot and everything is running fine.

For us, what really solved the problem was:
select the data model in the Project navigator
select the configuration (Default for us)
in the Inspector -> File inspector change the data model version by clicking the small folder icon (below Location, find the red box in the screenshot below) and selection the correct .xcdatamodel file (notice no "d" at the end of the file). See the example where I've already changed from the version "1" (Notifications.xcdatamodel) to version "2" (Notifications 2.xcdatamodel visible in the screenshot).

Related

Xcode 8 can't open Model.xcdatamodeld

I am running macOS Sierra (Build 16A320), using Xcode 8.0 (8A218a) and have migrated all my code to Swift 3.
I can't open my Model.xcdatamodeld file anymore. Selecting it in the project navigator does not open up the "Core Data Model editor" view (not sure what it is called). I have tried restarting Xcode, but it does not work. I have tried deleting derived data, cleaning, does not work. I have tried double clicking, does not work.
Model.xcdatamodeld is visible in the Project navigator view, but it is not possible to interact with it (other than right clicking), nothing happens when I click or double click on it.
EDIT: Problem solved, see my answer below
Okay so I solved it... Hmm not sure why but seems like some part of the Swift Migration guide messed up the Model.
SOLUTION:
Remove the model from the project (was not even asked about trash or
reference, but delete reference if asked of course).
Re-add the file
This resulted in this Git change (screenshot from SourceTree):
As you can see, the Model.xcdatamodel (note difference vs Model.xcdatamodeld) file was missing! I guess it somehow got messed up during the -> Swift 3 migration?
Anyway, now it works! :)

XCode Source Control - Discard Changes Deleted imported files

I am doing a game for iPhone and iPad using SpriteBuilder. SpriteBuilder makes a couple of files in the same folder as the XCode project. I was using Source Control and I just made a commit, then I changed a little bit of the code in the XCode (I changed nothing of the spritebuilder files) and then I changed my mind and I wanted to go back to the commit I made. So I did source control -> discard changes. The XCode successfully replaced the new code with the old code but it erased most of my SpriteBuilder files!!
How do I get my SpriteBuilder files again?
Screenshot of the last commit. You can see that xcode knows when the spritebuilder files are changed so it should keep them no?
Unfortunately the way Xcode calls Git appears to do this. All may not be lost, however. Check the trash for your missing files.
Quit Xcode.
Open the file you wish to bring back your lost changes to using TextEdit.
Go to File -> Revert To -> Browse All Versions...
Scroll through the available versions. Hopefully you will have many available to choose from.
Select a version and hit Restore.
Follow 1-5 for all necessary files.
Launch Xcode. You should now see the M next to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).

Project Crashes After Rename

If I change the name of my iOS project in XCode either in in the navigator view:
What is the equivalent of Project->Rename in Xcode 4
Or in the Inspector, like this:
http://woolybeastsoftware.com/woolyblog/2012/01/22/xcode-4-renaming-projects/
...XCode quits unexpectedly? Anybody run into this problem?
Why does this happen and how can you avoid it?
If your Xcode project is corrupted, you can do the following,
In finder, right click on your .xcodeproject file and click on show package
contents.
Then right click on your project.pbxproj and open it in some text
editor.
Then search for the previous project name which you used and manually rename
it to the new name.
Save it after changing and then reopen the project.
The reason is because your project.pbxproj file which stores all details related to the project got corrupted which causes the Xcode to not able to parse it and hence it crashes. Ideally this shouldn't happen while renaming, but in your case somehow it got corrupted. –
There is a more simpler way: go to Build Settings -> search for "Product Name" and rename it.
I got this problem after upgrading to Xcode 6.3. After downgrading to 6.2 it worked fine again. So it seems that some versions of Xcode handle renaming better than others.
You find an old version here: https://developer.apple.com/downloads/index.action?name=Xcode Hope this can help someone.

After changing project name, cannot find version setting

Using XCode 4 for iOS. I changed the project name of my program to something more user friendly and readable. I can no longer find the version setting.
Is there another setting I need to change to view and edit version/build?
Thanks...Rick
I have tried in XCode and rename the project.
The Xcode will automatically ask you to rename the target etc.
Afterward, I could still find the version and build in Target summary and info.
I rename the project name in the following way :
1. Select Project (the top row with blue icon)
2. Press Enter
3. Rename
4. And continue with xCode suggestion for renaming other related files
I hope this help

Unable to add datamodel in xcode4

I'm porting my iphone app to ipad, and therefore created a completely new project. After programming a while, i wanted to import the coredata model from my iphone project, so i can have the same coredata storage layout. but for some reason, xcode 4.2 wont let me use the imported model. after drag-and-dropping the versioned model (foobar.xcdatamodeld) into my ipad project (copying it to the destination), i am unable to select the current version, and the model will not show the arrow-indicator as well as no sub-models in the file-list on the left side of xcode.
even if i create a new datamodel (file -> new...), i get the same behaviour. i can't edit the model, because appearently it is not opened (clicking on the model in the file list will not change the editor window in the middle), i cannot add a version to the model (the menu item unter "editor" is not present), and i can't select any current version.
i noticed that the object inspector will state a path that is "Relative to group", with the path beeing "../foobar.xcdatamodeld" (which is "foobar.xcdatamodeld" in my iphone project), and the full path is beeing blank.
i even edited the model and xcode project files through vi, to make it look like the iphone ones, with no success.
so, right now i can't neither add a new datamodel, nor import the existing model.
can anyone help?
i have no idea if it's related, but i ran into a weird thing earlier today when copying resources from one project to another. i did the same thing (made sure i selected copy files into destination's group folder etc) and it didn't actually copy them - it was referring to the files in the project i was copying from. weirder still, the project couldn't actually "see" them (the file names were red).
i ended up getting around it by manually copying them into the "to" project's directory, and adding them from there.

Resources