How to Delete an Unused Data Model Version in Xcode

28 February 2025 Stephan Petzl Leave a comment Xcode

Deleting an outdated or unused data model version in Xcode can sometimes be a bit tricky, especially when the option appears disabled. This guide will walk you through the process, ensuring you can clean up your project efficiently without running into complications.

Steps to Remove an Old Data Model Version

Follow these steps to safely remove an old data model version from your Xcode project:

  1. Set the Current Version: In Xcode, set the current version of the model to one that you want to keep. This ensures you are not deleting a version that is actively in use.
  2. Remove Reference from Project: Right-click on the .xcdatamodeld file in your project and select Delete, then choose Remove Reference Only. This action will not delete the file from your disk but will remove it from the project view.
  3. Access Package Contents: Navigate to Finder, right-click on the .xcdatamodeld file, and select Show Package Contents. This reveals the internal components of your data model bundle.
  4. Delete Unwanted Model: Inside the package contents, locate and delete the .xcdatamodel file(s) that you no longer need.
  5. Re-add to Project: Finally, drag and drop the .xcdatamodeld file back into your Xcode project to re-establish the reference, now without the unwanted versions.

This method is straightforward and avoids the need to manually edit project metadata files, thus reducing the risk of errors.

Alternative Method for Xcode 10.3 and Later

If you are using Xcode 10.3 or later, you can follow this alternative method to avoid potential ordering issues:

  1. Select any model version other than the one you wish to delete.
  2. In Xcode, right-click the .xcdatamodeld file and choose Show in Finder.
  3. Close Xcode to prevent conflicts during the editing process.
  4. In Finder, right-click the file again and select Show Package Contents.
  5. Note the name of the unwanted model and delete it from Finder.
  6. Navigate to your project file (.xcodeproj) and open it with a text editor such as Atom.
  7. In the editor, find the project.pbxproj file and remove all lines containing the model name you deleted.
  8. Re-open Xcode to see the changes reflected in your project.

Enhancing Your Development Process with Repeato

While managing data models in Xcode can be tedious, automating other aspects of your development process can save significant time and effort. This is where Repeato can make a substantial difference. Repeato, a no-code test automation tool for iOS, Android, and web apps, simplifies the creation, execution, and maintenance of automated tests. Its intuitive interface allows you to record tests quickly, and its robust AI and computer vision capabilities ensure reliable results. Additionally, Repeato supports complex automation tasks through command line scripts or JavaScript code, making it a versatile solution for modern development challenges. With Repeato, you can focus more on developing innovative features while ensuring your apps remain bug-free.

Like this article? there’s more where that came from!