简体   繁体   中英

Core Data versioning and SVN

I use Xcode Repositories for working with svn, and today i added a new version to my Core Data Model and tried to commit it. But Xcode through an error:

svn: Commit failed (details follow):
svn: Entry for '/Users/user/Desktop/project/Core Data/Translator.xcdatamodeld/Translator 2.0.xcdatamodel/contents' is marked as 'copied' but is not itself scheduled
for addition.  Perhaps you're committing a target that is
inside an unversioned (or not-yet-versioned) directory?

I think that the problem is that svn treates xcdatamodel as a dolder, and since it is changed it doesn's under version control anymore. But what should i do then? Don't commit new models and transfer it manually?)

I would recommend writing a subversion checkout/commit hook that would create a zip or tar archive of the Translator.xcdatamodeld directory, and then check that in. The actual xcdatamodeld directory would be ignored. (It would probably be best not to compress the archive, since compressing will just make it harder for svn to compute diffs and make your repository larger.)

The problem is that when you start with the first data model, Xcode creates a file, let's say: myProject.xcdatamodeld

Let's say that you create, via menu Editor > Add Model Version , a second version of the model named _myProject_v2_. What Xcode actually does is: it creates a folder, named as your original model, and copies the original model in a subfolder, then creates a second subfolder with a file containing the new version:

myProject.xcdatamodeld
    |
    +- myProject.xcdatamodel
    |           |
    |           +- contents (a file containing the actual model)
    |
    +- myProject_v2.xcdatamodel
                |
                +- contents (a file containing the 2nd version of the model)

So SVN gets confused, because what he thinks is a file (the original myProject.xcdatamodeld) and which is stored in SVN, is now a folder, with subfolders. And moreover, these subfolders, being created by XCode, gets eventually their hidden .svn folder.. so my solution is:

  1. delete folder myProject.xcdatamodeld from SVN
  2. do a commit of the rest
  3. close Xcode and rename your folder project: eh: _projectFolder_old_
  4. do a checkout of the project, which hopefully will not have a myProject.xcdatamodeld
  5. from within xcode, create a bogus data model named myProject . Don't create anything in the model, it's useless
  6. version it, with Editor > Add Model Version
  7. close XCode
  8. open in Finder your old datamodel in myProject.xcdatamodeld (right mouse button, Show package contents )
  9. open in Finder your original model and copy the contents file from *projectFolder_old/myProject.xcdatamodeld/myProject.xcdatamodel* to the new project: projectFolder/myProject.xcdatamodeld/myProject.xcdatamodel (you will need to do a couple of Show Package Contents
  10. repeat for your second version, copy the contents file from *projectFolder_old/myProject.xcdatamodeld/myProject_v2.xcdatamodel* to the new project: *projectFolder/myProject.xcdatamodeld/myProject_v2.xcdatamodel*
  11. reopen Xcode and check everything is correct
  12. add to svn the files, if not already added, and do a commit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM