0

I recently found a problem in my Compile Sources Build Phase, it was compiling MyDB.xcdatamodeld and MyDB.xcdatamodel into the build (probably left over from some migration between Xcode versions or something). This wasn't a problem until I recently started using a library that uses:

[NSManagedObjectModel mergedModelFromBundles:nil]

Which goes and finds both of the MyDB files and throws an error that it can't merge duplicate entities, similar to this issue Core Data: Error, "Can't Merge Models With Two Different Entities Named 'foo' ". The problem w/their solution though is that it involves deleting the app :)

I fixed the problem in my Build Phase (I removed the MyDB.xcdatamodel line) and if I do a fresh install of the app it works fine, but if I install the app over an existing install (ie an update) then I still get the same DB error about duplicate entities. I imagine this is because the MyDB.xcdatamodel file is still hanging out in the user's bundle.

So my question is: how can I remove this file from existing install's bundles?

Community
  • 1
  • 1
Shizam
  • 9,627
  • 8
  • 51
  • 82

2 Answers2

1

I believe old files get left behind only when you install an application during development through Xcode. Try testing an upgrade done through ad hoc distribution instead, you shouldn't see this problem.

Jim
  • 72,985
  • 14
  • 101
  • 108
-2

Clean all your targets and delete the app on the simulator/device? :)

  • The problem is this doesn't fix the problem for the millions of users to already have the application installed :) – Shizam May 09 '12 at 16:42