Xcode does not reload project when it appears after disappearing from repo

Originator:igeek1
Number:rdar://13124543 Date Originated:31-Jan-2013 10:54 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode Version 4.6 (4H127)
Classification:UI/Usability Reproducible:Always
 
Summary:
If a currently open project disappears because I switched branches, and then reappears when I switch back, it does not load in Xcode.

Steps to Reproduce:
1. cd Desktop
2. mkdir test
3. cd test
4. git init
5. Create a file called readme.txt in the test directory. Type some text into it and save it.
6. Stage and commit readme.txt:
6a. git add readme.txt
6b. git commit -m "Initial commit"
7. git branch dev-branch
8. git checkout dev-branch
9. Open Xcode 4.6.
10. Create a new Xcode project. Choose Single View iOS application and click Next.
11. Name the project MyProject and click Next.
12. Do not let Xcode create a local git repository. Save the project in the test folder from step 2.
13. Make sure to leave the project open in Xcode for the next steps.
14. git commit -m "New iOS app"
15. git checkout master
16. git checkout dev-branch

After step 15, the Xcode project window goes empty. MyProject still shows up in the left sidebar, but there is nothing under it. A sigle build error appears: "Workspace Integrity: Couln't load project." This is expected, and is how it has always been as far as I know.

Expected Results:
After step 16, when the project file reappears in the file system as a result of switching back to dev-branch, Xcode should reload the project, preferably with the same disclosure triangles open in the sidebar as before switching branches.

Actual Results:
After switching back to the branch that contains the project, the Xcode window does not change. It stays empty. Clicking the project in the sidebar results in the modal dialog, "The file couldn’t be opened." I have to close the window, find the project, reopen it, and then reopen all the disclosure triangles in the sidebar because none of my interface state is preserved.

Regression:
This exists in Xcode 4.5 as well. I haven't tested it with earlier versions.

Notes:
I often switch to another branch just to look at something or pull a change, then switch back. It would be nice if that didn't interrupt my work.

Comments

because none of my interface state is preserved.2N3906

By joey899244 at Feb. 2, 2013, 9:15 a.m. (reply...)

Added this comment to the bug

I thought this might be useful in reproducing my problem. Here is the contents of my global .gitignore file:

*~

.DS_Store

xcuserdata

xcuserstate

*.xcworkspacedata


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!