Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to Xcode 7 creates "Missing current version declaration" warning on CoreData model

Figured I'd post a complete question/answer here to the known bug:

When upgrading to Xcode 7 (stable/beta) from a previous release, your build suddenly gives you a new warning: "Missing current version declaration" for your CoreData model file.

Worst of all, double-clicking this warning goes nowhere, & there are no obvious hints within Xcode as to the resolution. How do you resolve this issue?

like image 330
Sitric Avatar asked Jul 21 '15 21:07

Sitric


2 Answers

Note: This was tested on Xcode 6.4 & Xcode 7 beta 3 - As of Xcode 7 beta 4 there appears to be a built-in solution, and manually creating the file no longer works - see accepted answer

Open up Terminal, and navigate to your project directory & model file - your command should look something like this:

cd /Users/YOU/Documents/MyProject/MyProject/MyDataModel.xcdatamodeld

Now list all the contents of your data model directory:

ls -la

If you don't see a file called ".xccurrentversion", it needs to be created.

nano .xccurrentversion

Copy/paste the needed XML for the model version:

<?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>YOURDATAMODELNAME.xcdatamodel</string>  
</dict>  
</plist>

Replace YOURDATAMODELNAME with the name of the data model directory, minus the extension (e.g. MyDataModel.xcdatamodeld --> MyDataModel).

Now, likely you'll need to fix the permissions for the file:

chmod 775 .xccurrentversion

.. which is sufficient.

Clean the project, restart Xcode, rebuild - warning should go away.

Largely compiled from this thread, with some more specificity + permissions fix: https://forums.developer.apple.com/thread/8861

like image 97
Sitric Avatar answered Oct 18 '22 13:10

Sitric


While in Xcode’s Core Data model editor, in the menu bar select Editor -> Add Model Version.

enter image description here

Then in the version name you are free to specify what you like, you can just type in your model name. (verified on Xcode 7 beta 4)

(This will result in creation .xccurrentversion in your data model bundle)

like image 28
ambientlight Avatar answered Oct 18 '22 13:10

ambientlight