Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.xcodeproj file is lost, cannot be opened after a branch merge

Tags:

git

merge

xcode

I just merged one of the feature branches into develop branch, and since then, when I open Xcode, the .xcodeproj file seems lost, all files in the project navigator are gone also. click on the .xcodeproj file I get the following alert: The file couldn’t be opened.

This is although I am adding .xcodeproj to the .gitignore file across all the branches. Have you encounter such situation?

like image 766
Malloc Avatar asked Nov 20 '13 20:11

Malloc


People also ask

What is Project Pbxproj?

project. pbxproj is an important file in the Xcode configuration bundle. It is responsible for maintaining references to all of the linked files and their groupings, linked frameworks, and most importantly, the project's build settings.

Where is Pbxproj file in Xcode?

Even though the Xcode interface shows the project. pbxproj file for the project in the IDE's user interface, the actual PBXPROJ file is stored within the . XCODEPROJ file for the project.


2 Answers

Basically, in a project if more than one developer are working and one developer has added some files(it may be .h,.m or any .png) and commits the project including .xcodeProj in source control management.

But due to some reason developer removes files or images from the project and also removes the use of those files or images from the project but forgets to commit the.xcodeProj project file.

If another developer checks out from the source control management and runs the application,he would get error messge error:path file/image name:No such file or directory. So to avoid the error to run the application at our end successfully we can follow below steps

  1. Right click on projectname.xcodeproj and click on showpackagecontent.
  2. There we will get another file as project.pbxproj.
  3. Open that file on text edit and remove the lines where the file or image has been mentioned.
  4. Save the file. And finally run the application it will work.
like image 179
Gal Blank Avatar answered Oct 13 '22 20:10

Gal Blank


This might be caused by unresolved merge conflicts. In that case the XML structure is broken, so Xcode can't read it.

In that case you can try this:

  • In finder right click on the .xcodeproj and choose 'Show Package contents'.

  • Open project.pbxproj in an text editor (this is the actual project file, and has to be valid XML)

  • Check for merge conflicts (look for <<<<<<< and >>>>>>>) and manually resolve them (be careful!), and ensure the file has valid XML format

  • Save the file

  • Try again opening the .xcodeproj with Xcode

There might be better ways of resolving the conflicts, but this worked for me multiple times. You also might want to check out this question: How to resolve merge conflicts in Git?

like image 30
Leijonien Avatar answered Oct 13 '22 20:10

Leijonien