Name of .xcdatamodel gets cleared out automtically from pbxproj file.

I have added core data to my project and below is the code block of how it's section in pbxproj file looks like.

However whenever I make any changes to the project i.e. changing build version or adding a deleting new files to the project, I have noticed "name = "sample-app.xcdatamodeld";" gets deleted automatically from the project file and I have to manually reverse that change.

Am I missing any setting for core data or is it a bug somewhere in XCode or Core Data? I am using XCode 15.

/* Begin XCVersionGroup section */
		4683EC5B2C10F8B800A5081B /* sample-app.xcdatamodeld */ = {
			isa = XCVersionGroup;
			children = (
				4683EC5C2C10F8B800A5081B /* sample-app.xcdatamodel */,
			);
			currentVersion = 4683EC5C2C10F8B800A5081B /* sample-app.xcdatamodel */;
			name = "sample-app.xcdatamodeld";
			path = "sample-app.xcdatamodeld";
			sourceTree = "<group>";
			versionGroupType = wrapper.xcdatamodel;
		};
/* End XCVersionGroup section */
Answered by DTS Engineer in 803840022

I don't see the "name = <the model file name>" line is generated in any case (by following the steps you provided), though I am using Xcode 16, which may behave differently from Xcode 15.

Since the line is a part of the Xcode project file, Xcode folks will have the final answer. My best guess is that it is probably used by an earlier version of Xcode, but not any more by Xcode 16, and probably 15 as well given that Xcode 15 removes the line when you change the project settings. If you don't see that removing the line has any side effect, you can probably go ahead to do so.

Also, Xcode 16 is now RC. If it works for you without the line, I won't worry too much.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I am curious how you added Core Data to your project. Did you manually change the Xcode project file in some way? If you can share your detailed steps, I may be able to comment.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Thanks for your response!

I haven't changed the Xcode project file manually, but I did create a sample project on the side and followed the steps of what I had done.

If I create data model file (.xcdatamodeld) at main project level, then the project file doesn't have "name" property in it and the path to the data model is also correct. I was trying to sort the project into modules and folders and I created a specific folder for data model and moved ".xcdatamodeld" under that folder. That's when "name" gets added to project file and even the path of the data model file changes.

Here is what you can try:

  • Create a sample app and add data model file to it at main project level.
  • Check project file and you won't see "name = "sample-app.xcdatamodeld";" in it.
  • Now create a new group/folder at main project level and move the data model file under it.
  • Check the project file and you will see "name = "sample-app.xcdatamodeld";" being added to it.

Is this expected?

I thought "name = "sample-app.xcdatamodeld";" got added when I first created data model file, but now I understand that it is getting added only after I move the data model file under a folder.

So my question now - is "name = "sample-app.xcdatamodeld";" expected?

Accepted Answer

I don't see the "name = <the model file name>" line is generated in any case (by following the steps you provided), though I am using Xcode 16, which may behave differently from Xcode 15.

Since the line is a part of the Xcode project file, Xcode folks will have the final answer. My best guess is that it is probably used by an earlier version of Xcode, but not any more by Xcode 16, and probably 15 as well given that Xcode 15 removes the line when you change the project settings. If you don't see that removing the line has any side effect, you can probably go ahead to do so.

Also, Xcode 16 is now RC. If it works for you without the line, I won't worry too much.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Thanks for the quick response!

I had created 'xcdatamodel' file using Xcode 15 and moved it under a folder using Xcode 15 as well which added the name property to project file. I later moved out the 'xcdatamodel' file back to the main level of the project and had deleted the folder and hence I am seeing the 'name' property being deleted from the project file whenever I make any changes to the project.

I had came across a post on Stack Overflow as well where they were seeing something similar in 'xcdatamodel' section in project file i.e. name being added or the path was changed, using Xcode 15.

In my case, I deleted the line manually from the app's project file and it didn't cause any issue to my project.

Thanks again!

Name of .xcdatamodel gets cleared out automtically from pbxproj file.
 
 
Q