Reputation:
I have been working for a while to create an iPhone app. Today when my battery was low, I was working and constantly saving my source files then the power went out...
Now when I plugged my computer back in and it is getting good power I try to open my project file and I get an error:
Unable to Open Project
Project ... cannot be opened because the project file cannot be parsed.
Is there a way that people know of that I can recover from this? I tried using an older project file and re inserting it and then compiling. It gives me a funky error which is probably because it isn't finding all the files it wants...
I really don't want to rebuild my project from scratch if possible.
Ok, I did a diff between this and a slightly older project file that worked and saw that there was some corruption in the file. After merging them (the good and newest parts) it is now working.
Great points about the SVN. I have one, but there has been some funkiness trying to sync XCode with it. I'll definitely spend more time with it now... ;-)
Upvotes: 106
Views: 112657
Reputation: 526
In my experience, I needed a combination of tactics for this:
A-
1-Use git merge from the command line to figure out what files need to be resolved
2-Use git add or git rm as appropriate with those files
3-Use git commit to finish the merger
B- 1-for the .pbxproj I removed the <<<< , >>>> and the =====
2- used https://github.com/Serchinastico/Kin to find merging errors, and using SnoopyProtocol's answer I fixed those issues
Note: at one point the only error Kin was showing was: ERROR: line 1197:40 mismatched input '1' expecting NON_QUOTED_STRING
which didn't need to be fixed for the Xcode project to be openable
Upvotes: 1
Reputation: 1253
If you ever merge and still get problems that dont know what they are, I mean not the obvious marks of a diff
<<<<<
....
======
>>>>>>
Then you can analise your project files with https://github.com/Karumi/Kin, install it and use it
kin project.pbxproj
It has make extrange erros that doesn't allow open the project more easy to understand and solve (ones of hashes, groups and so on).
And by the way, this could also be helpful, thought I have not used it try to diff 2 versions of your project files https://github.com/bloomberg/xcdiff so this will give you really what is going on.
Upvotes: 1
Reputation: 1
In case if you did not find in Text === or <<< or >>>> like was for me problem was really simple and fun... I change name of App in Xcode, but not change it in UnityProjectSettings before build - that was the problem...
Upvotes: 0
Reputation: 39
Steps to be followed:- 1.Navigate to folder where your projectName.xcodeproj 2.Right click and select 'Show Package Contents'. You will be able to see list of files with .pbxproj extension. 3.Select project.pbxproj. Right click and open this file using 'Text Edit'. 4.You will be able to see <<<<<<, ============ and >>>>>>>>>>. These are generally conflicts that arise when you take update from Sourcetree/SVN/GITLAB. Delete these and save file. 5.Now, you'll be able to open project without any error message.
Upvotes: 3
Reputation: 477
By reverting, you can undo pulled code.
If you want to undo that pull request just put this command on project path
--> git merge --abort
Upvotes: 0
Reputation: 1372
Analyse the syntax of your project file. Check it inside your project in terminal:
plutil -lint project.pbxproj
This will show you the errors from the parser.
Possible problem: Some projects set git merging strategy union
for project files. This works for most of the times, but will silently kill your project file if it fails. This strategy is defined in the .gitattributes
file in your repository.
Upvotes: 7
Reputation: 329
I faced the same problem recently when trying to merge my branch with a remote branch. However, none of the above solutions seemed appropriate to my problem.
There were no merge conflicts between the project.pbxproj file in my branch or the remote branch. However, my projectName.xcodeproj file would refuse to open for the same reason as shown in the asked question.
My solution was to look through the project.pbxproj using a text editor and find if there were any irregularities in the file syntax (for e.g. an extra curly bracket). I sped this process up by focusing on the lines which were inserted or deleted in old file as compared to the merged file. On closer examination, I found the cause of my problem was the repetition of the following line :
xxxxxxxxxxxxx /* [CP] Check Pods Manifest.lock */ = {
in my merged file. This led to an unclosed curly bracket and consequent invalid pbxproj syntax. Deleting the above line fixed my problem.
Upvotes: 3
Reputation: 910
I just ran into same problem. I removed generated strings by git as always but Xcode still refused to open .xcodeproj file. But everything was correct, no missing brackets etc. Finally I tried to quit Xcode and open project when Xcode was closed.. then it worked. I hope this helps someone.
EDIT:
for resolving conflicts in your .xcodeproj file you can use this handy script:
Here is the script:
projectfile=find -d . -name 'project.pbxproj'
projectdir=echo *.xcodeproj
projectfile="${projectdir}/project.pbxproj"
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile mv $tempfile $projectfile
Run it from terminal using sh command: sh resolve_conflicts.sh
Upvotes: 2
Reputation: 36447
I had similar issue.
Below are steps to resolve it:
Navigate to folder where your projectName.xcodeproj
.
Right click and select 'Show Package Contents
'. You will be able to see list of files with .pbxproj
extension.
Select project.pbxproj
. Right click and open this file using 'Text Edit
'.
You will be able to see <<<<<< .mine
, ============
and >>>>>>>>>> .r123
. These are generally conflicts that arise when you take update from SVN.
Delete these and save file.
Now, you'll be able to open project without any error message.
Upvotes: 26
Reputation: 911
Muhammad's answer was very helpful (and helped lead to my fix). However, simply removing the >>>>>>> ======= <<<<<<< wasn't enough to fix the parse issue in the project.pbxproj (for me) when keeping changes from both branches after a merge.
I had a merge conflict in the PBXGroup section (whose beginning is indicated by a block comment like this: /* Begin PBXGroup section */) of the project.pbxproj file. However, the problem I encountered can occur in other places in the project.pbxproj file as well.
Below is a simplification of the merge conflict I encountered:
<<<<<<< HEAD
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
=======
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
>>>>>>> branch name
sourceTree = "<group>";
};
When i removed the merge conflict markers this is what I was left with:
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
Normally, removing the merge conflict markers would fix the parse issue in the project.pbxproj file and restore the workspace integrity. This time it didn't.
Below is what I did to solve the issue:
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
id = {
isa = PBXGroup;
children = (
id
);
name = "Your Group Name";
sourceTree = "<group>";
};
I actually had to add 2 lines at the end of the first PBXGroup.
You can see that if I would have chosen to discard the changes from either Head or the merging branch, there wouldn't have been a parse issue! However, in my case I wanted to keep both groups I added from each branch and simply removing the merge markers wasn't enough; I had to add extra lines to the project.pbxproj file in order to maintain correct formatting.
So, if you're running into parsing issues after you thought you'd resolved all you're merge conflicts, you might want to take a closer look at the .pbxproj and make sure there aren't any formatting problems!
Upvotes: 54
Reputation: 15
Goto PhoneGapTest>>platform Then delete the folder ios after that go to terminal then type: sudo phonegap build ios after that you can run the project
Upvotes: 0
Reputation: 1
Try to find HEAD and _HEAD between the lines and delete this words in project.pbxproj. Backup this file before doing this..
Upvotes: 0
Reputation: 2514
Visual analysis of the Xcode project file did not help me to locate error after merging. After looking to syslog found such line when Xcode trying to parse the file:
2/7/14 12:39:12.792 PM Xcode[9949]: CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 4426. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
After fixing that project can be opened ok.
Upvotes: 25
Reputation: 1008
I got this exact same error because Cordova will allow you to create a project with spaces in it, and Xcode doesn't know how to deal.
Upvotes: 28
Reputation: 2579
I came across this problem and my senior told me about a solution i.e:
Right click on your projectname.xcodeproj
file here projectname
will be the name of your project. Now after right clicked select Show Packages Contents. After that open your projectname.pbxproj
file in a text editor. Now search for the line containing <<<<<<< .mine
, =======
and >>>>>>> .r
. For example in my case it looked liked this
<<<<<<< .mine
9ADAAC6A15DCEF6A0019ACA8 .... in Resources */,
=======
52FD7F3D15DCEAEF009E9322 ... in Resources */,
>>>>>>> .r269
Now remove those <<<<<<< .mine
, =======
and >>>>>>> .r
lines so it would look like this
9ADAAC6A15DCEF6A0019ACA8 /* BuyPriceBtn.png in Resources */,
52FD7F3D15DCEAEF009E9322 /* discussionForm.zip in Resources */,
Now save and open your Xcode project and build it. Everything will be fine.
Upvotes: 242
Reputation: 29795
Just check the project.pbproject file and do a diff against a working version of the project file.
Often times this happens when you have conflicts from a version control system like posted here: User file cannot be parsed in subversion in MAC iphone SDK
Upvotes: 0
Reputation: 1
change your current project folder nam and checkout module the same project.then add the current file changes.
Upvotes: 0
Reputation:
subversion will corrupt my project file after a svn up on an almost weekly basis. I'm trying to figure out why it does this right now and came across this problem.
Upvotes: -2
Reputation: 4171
And once you get things working again you should look into using something like subversion or mercurial for backup and revision control. Remember that he electrons don't always go where they are supposed to, backup early and often!
Upvotes: 0
Reputation: 40515
It sounds like you're going to have to create a new project in Xcode, go into the old directory, and drag all your source files, nibs, and resources into the Xcode files sidebar in the new project. It shouldn't take more than a few minutes, unless you really did a lot of work with custom build settings or targets. Either that, or revert to the last check-in in your source control and manually add any code files which changed between now and then.
Upvotes: 0