This keeps happening to me when I drag and drop frameworks into the project, in Xcode 16. I followed the steps above and it made no difference in my case.
To fix it, I remove xcshareddata and xcuserdata from the project file. This may need to be done from the workspace file too, if you have one. This is the full list of steps I take:
1. Xcode > Product > Clean Build Folder
2. Close the project and Xcode
3. Delete DerivedData folder
<User>/Library/Developer/Xcode/DerivedData
Next are the important steps to fully solve the problem.
4. In the file system; Show Package Contents of the project file [ProjectName].xcodeproj
5. Delete folders:
xcshareddata
xcuserdata
Now, open the project, Clean Build Folder (if you didn’t before) and compile.
Note: this also worked for a project that was crashing when I opened it as noted in this post:
Xcode Crashing When Opening Project File