Xcode bug when displaying an xcodeproj - xcode

I'm currently using Xcode 7.1 and I came across this:
I'm in no case a seasoned Mac user and I'm unable to revert to the full display where I had the project's info on the center of the screen.
Does someone more experienced or less dumb than me know how I can fix this?

When I've seen this before, it's largely because of the .pbxproj file being corrupted - and this only really happens (??) if there is something that is externally modifying it, like a git merge.
In order to verify - and fix it - you need to:
a) Go to the project in Finder (and then close it in Xcode)
b) Ctrl-click it and select 'Show Package Contents'
c) open the project.pbxproj file in a text editor and finally
d) fix any information that is stopping Xcode from reading the XML structure and displaying it properly in the IDE.
With git, the error is usually unmergeable differences in the Build Settings - Teams, Profiles, Id's, etc. So you can either scroll very carefully through all 500+ lines of markup, or simply search for the git HEAD markers that look like chains of < or > lines - eg. '<<<<<<<<<<< HEAD '
Remove those, fix the conflicts, save the file, and reopen the Project.
Should be all good then!

Related

Xcode 7.1 "Couldn't Load Project" after Syncing to GitHub

First I wasn't able to get anything on the Utilities tab on the far top left for the Identity Inspector, Size Inspector, etc.
When I tap on viewController I can't access anything. I can't navigate through the project either. Has this happened to anyone? I haven't changed the location of the project. However, I have synced the project to Github from my desktop. I'm using OS X El Capitan. This has happened for 2 projects... This is what it looks like:
This is what it looks like when I click the error:
Any help is appreciated.
Your project file has broken. Open up your project's root directory using SourceTree. You will see all the conflicting files.
Cntrl click on the project file and launch the external merge tool.
This should open FileMerge by default. You can scroll through the file to reveal the conflicts. The tool is a bit buggy and you might have to first scroll through all the text before the red markers are revealed in the right gutter.
On each of the red marked conflicts, select the highlighted section and choose the correct code. On the top of each section, it will say which repo is which, local vs remote.
At the bottom of the FileMerge app there is an option for resolving the selected conflict. Left, Right, Left then Right, etc. Once you have fixed all the conflicts, cmd + s to save it, then cmd + q to quit it. SourceTree should then show that the file is no longer conlficting.
If you then open Xcode you will get your file tree back, where you can then fix the remaining conflicts in Xcode or using the previous technique in SourceTree.
This situation should highlight another issue, you are doing something incorrectly with git. Maybe force pushing without pulling from the remote.
commit, pull, possibly fix conflicts, push.

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

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?
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?
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
Right click on projectname.xcodeproj and click on showpackagecontent.
There we will get another file as project.pbxproj.
Open that file on text edit and remove the lines where the file or image has been mentioned.
Save the file.
And finally run the application it will work.
I know this is an old thread, but I had this issue today. I initially shrugged this answer as I don't have multiple users on the project, but I:
right clicked on the .xcodeproj and chose 'Show Package contents'.
From here, I noticed I couldn't open the project.pbxproj. I 'didn't have the necessary permissions', so I...
changed the permissions on the file to everyone can read/write, and then I was able to open the project without issue in Xcode.
not sure where this got crossed for me, but in case anyone sees this and has a similar issue and it's not a merging conflict.
Faced with the fact that the above methods did not work for me, my reason was this: when merging two files, the structure inside of project.pbxproj file overlapped and was broken, all I did was again thoroughly scan the conflicting sites for the correct syntax {some code} , availability ';' etc.

Xcode commit window -- show unix-diff-like diff (don't show the whole file)

Talking about latest Xcode (4.2.1) on latest Mac OS X Lion (10.7.3).
When you press option-command-C, Xcode pulls up a window showing the new file and the old revision of the file side-by-side.
I like the elegance of the interface; however, sometimes it's not ideal for longer files.
The problem is, Xcode shows you the ENTIRE file, so in order to see all the changes, you basically have to scroll through the whole file. This is especially annoying if you just made a change consisting of a few lines -- you still have to scroll through the whole file to check you accidentally aren't commiting something else.
Is there a way to make Xcode behave like the UNIX diff, which shows you ONLY the changed portions of the files (plus a few lines of context)?
This is not exactly what I was looking for, but it helps nevertheless:
I found out you can click on the region between the two files, and then use up/down arrow keys to directly move between regions which have changed.
This simplifies viewing the diffs greatly.

ios file corruption

Ok so some how 2 of my classes had ended up in a weird directory
projectname>projectname.xcodeproj>
In my infinite wisdom I tried to transfer these to the proper directory were the rest of my classes are (projectname directory)
However now I cant compile due to it not being able to find certain files
what file can I edit to check to see where it's looking for these files?
UPDATE 1
in response to the first answer I have tried readding the files. which has netted me some different errors. Specifically that Cameleon-Prefix.pch, no matter how many times I re add it always shows red.
A quick fix for this is to delete the files from Xcode, but in the confirmation dialog, choose to just release the references. Then add the files again (from the File menu Add Files… item).
If you want to see where Xcode expects to find the files, choose the file in the navigator pane on the left, and set up the right hand pane with this configuration.
And from there you can click on the detail disclosure buttons to see even more.
Edited to add
Make sure this is the same file pointed to in your build settings:
Do a similar search for pch to make sure the same thing goes with the pch file

Xcode 4 adding images to a project

Coming from a background of Visual Studio I had no idea how good that IDE truly was until I had to work with Xcode. One of the more pressing oddities that it has just thrown up is the following.
I'm upgrading a project to a retina display and so have to add a bunch of new #X2 files. This is fine, I have the files and I go into Xcode, choose the project group where I want to add them, select them all and click 'Add'.
"Multiple errors occured" Xcode helpfully blurts and then returns to whatever it was doing before. No break down of what those errors might be, or what actually happened or why.
So I do some looking and some of the files are actually in the directory but Xcode ignores them, I can't figure out a way of adding them (it says they're already there!) but they won't appear in the xcode project.
Can I 'refresh' xcode so it looks in the directory and shows them?
==============================
PS. While I'm here and can rant a little, anyone with a VS background now using Xcode, am I wrong in thinking the following points are hugely annoying:
1) The debugger - frustratingly slow.
2) The file explorer - can't easily sort by name
3) The file explorer - column on the right listing the file names doesn't change the file highlight when you move from file to file within the editor window.
4) Adding files to a project - see above!
Some of these probably stem from lack of experience with the IDE but still, they irk.
Files in the XCode directories don't necessarily have to be in the project.
For some reason, XCode doesn't like overwriting files, and that's the warning message that I usually get when this happens too - "Multiple errors occured."
What I suggest you do is remove all of the #2x files from your project directory, and add them back into XCode using "Add Files..." Make sure you select "Copy files into project directory if necessary" though, otherwise they will just be referenced to their current location on disk.

Resources