iphoneiosxcode

Xcode freezes on startup while loading project


I am running Xcode 4.3.3 on the new Macbook Retina and out of the blues Xcode started freezing right after launching. I was in the middle of working on two projects so when Xcode starts up it immediately launches the two projects I was working on. The first one loads sometimes but the second one always freezes. Because the project launches right away I cannot access any of Xcode's features. I can't even figure out how to stop the project from launching on start up. Here is what I have done thus far:

  1. Rebooted comp - still launches projects and freezes
  2. Deleted everything in cache ~/Library/Developer/Xcode/DerivedData - still launches projects and freezes
  3. Uninstalled Xcode (hold click in Launchpad, click the (x)). Reinstalled Xcode. - Still launches the projects and freezes
  4. Moved my projects from original folder - Still launches the projects and freezes
  5. Created a new iOS user2 and launched Xcode - does NOT launch projects OR freeze yay!
  6. In user1 copied freezing project to external, logged in as user2, launched project - Does NOT freeze! But now I need to transfer my Xcode profile and certificates to the new user.

So what the heck is going on? I would prefer to use User1 and would like to actually solve the problem so that I don't need to make a new user if it happens again. (User n+1, indefinitely is not an attractive option).

Xcode freezing on startup


Solution

  • Check out this: (quoted from here)

    Restore sanity by not restoring

    Thanks to Lion's Restore feature, all the windows you left open in a given application remain open when you relaunch it. That's awesomely helpful in a Web browser or a text editor. In certain apps, however—particularly those where you rarely need to revisit the same documents—the feature is more of an annoyance. Window resuming is actually configured on an app-by-app basis. Here are the Terminal commands to disable Resume in Preview and QuickTime Player X:

    defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false
    
    defaults write com.apple.QuickTimePlayerX NSQuitAlwaysKeepsWindows -bool false
    

    Quit the apps before you try the commands. Again, swap "true" for "false" to reverse your change.

    You may be able to do something similar for Xcode.

    Otherwise, you can quit an application in Lion and discard the previously open windows by holding the option key while pressing CMD+Q. So you could try starting Xcode and quitting it with option held before it's had a chance to open your windows, then re-launch it and it shouldn't try to open the windows. Then you can try to fix the problem.

    Update: Here is some additional information from comments that solved the problem...

    Now to try and fix the project... Remove the following directories:

    MyProject.xcodeproj/xcuserdata
    MyProject.xcodeproj/project.xcworkspace/xcuserdata
    

    Those directories store things like window positions, what files are open, which project groups are expanded, etc. so one cause could be if you use source control across multiple machines that have the same username and those files aren't ignored (which they should be if you're using source control). Retina vs. non-retina or different versions of Xcode could use those files differently and the source-control merging could make them inconsistent. So make sure you remove and ignore these directories in source control so that they don't get re-added and cause the problem again.