Could not create bundle folder for versioned model

2019-02-09 15:39发布

问题:

I received project from other developer. Then i opened iOS project in Xcode and build it, i got error as below:

Volumes/Macintosh D/My workspace/HCProject/Model/HealthCareModel.xcdatamodeld:0: error: 
Could not create bundle folder for versioned model at
'/Users/TomMac/Library/Developer/Xcode/DerivedData/HCProject-bdxarurbgcdbaecxaoocaroetsjt/Build/Products/Debug-iphoneos/HCProject.app/HealthCareModel.momd'

Sorry if this is a basic question,please help me out. Thanks a lot.

回答1:

I don't know what causes this but I have experienced this error before.

The simplest way to fix it for me was to delete everything in in the "/Users/TomMac/Library/Developer/Xcode/DerivedData" directory.

There will be multiple directories under here you can probably get away with just deleting the one for the particular project that failed, but I haven't tested this.



回答2:

I had this same problem after a large Git merge. It turned out I had a duplicate .xcdatamodeld in my Compile Sources. I deleted one and haven't had the problem since.

In case you're not sure where to look, open your project in Xcode and click the project name to view it's properties. Go to the 'Build Phases' tab, then expand the 'Compile Sources' heading.



回答3:

  1. iOS simulator, Select "iOS Simulator"
  2. Select "Reset Content and Settings"


回答4:

I had this and I thought I'd got rid of it but it kept coming back every few builds. I now seem to have permanently got rid of it with the following steps:-

  1. Locate the model file in Finder and take a copy of it to another (safe) location.
  2. In Xcode, delete the file from the project (selecting move to trash).
  3. Build the project just to make sure the project file is saved.
  4. Close Xcode.
  5. Locate the derived data directory in Finder and delete everything. (I actually deleted the entire DerivedData directory just to be sure).
  6. Re-open XCode.
  7. Copy the model file back from your safe location to your project directory location.
  8. Drag it into the Xcode project navigator in order to put it back in the project.
  9. Build - it should now work...


回答5:

I had same issue and got it resolved by deleting content of derived data.

Below is step for the same :

1. Press cmd + comma (,) shortcut key to open preference window of Xcode.
   Or Goto Xcode menu on top and select Preference 

2. Select Locations tab present in last 

3. You can see Derived Data under Locations section

4. Click on small arrow present next to path. This open directory where project’s derived data content is present.

5. Select your project and delete it. Also delete the module cache folder.
    Note : You can even delete all content of Derived Data folder. 

   The content of this folder is generated again when it run. It is like cache.

 6. Quit your project

 7. Open your project. 

 8. Clean your project (cmd+shift+k)

 9. Build your project. This should build your project with no issues.


回答6:

I had the same problem this morning. After multiple cleans, Xcode restarts, and finally a system restart, I looked in the system log. I found this error message that corresponded to the time of the build error.

"Interface Builder Cocoa Touch Tool[89487]: BUG in libdispatch client: kevent[EVFILT_VNODE] add: "Bad file descriptor" - 0x9"

I changed permissions on Library/Developer/ folder and granted read/write privileges to "everyone", then restarted Xcode. The build was successful.

I don't know for certain that the build error was caused by a permissions problem but it's worth a try. (If you have a lot of projects in the Developer folder, the permissions change can take several minutes to complete.)



回答7:

In my case it was a duplicate version of the data model. Right click on the .xcdatamodel file in your project explorer and select "Show in Finder". Check for duplicates and delete them.



回答8:

In my case I had to follow two steps to get this entirely fixed:

  1. Delete the problematic version's hidden files. Note that FILENAME.xcdatamodeld is a folder and if you browse it you'll see the different versions you have there. The one that gave me the error was still there so I first had to look for hidden files and then delete it.

  2. Clean Xcode's DerivedData folder as suggested by others here.

Hope this helps folks.



回答9:

In my case my testsFileName.xctest (in workspace > Products > testsFileName.xctest) somehow has the application target as his target membership.



标签: iphone ios ios6