Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode freezes on startup while loading project

Tags:

xcode

ios

iphone

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

like image 610
BenHedges Avatar asked Jun 28 '12 14:06

BenHedges


4 Answers

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.

like image 73
jhabbott Avatar answered Nov 18 '22 19:11

jhabbott


What fixed this for me was removing unsaved document in ~/Library/Autosave Information. After Xcode launched without any problem.

like image 45
Montas Avatar answered Nov 18 '22 17:11

Montas


Using answer in apple.stackexchange.com did the trick for me:

Removing the ~/Library/Saved Application State/com.apple.dt.Xcode.savedState/ directory might help.

If this did not work, then remove ~/Library/Developer (brought from here and here)

like image 22
VSB Avatar answered Nov 18 '22 18:11

VSB


Open your project and then right click on yourprojectname.xcodeproj then click on Show package contents.

There you're going to see the xcuserdata. Delete it.

Next, right click in project.xcworkspace, click on Show package contents and delete the xcurserdata.

At the end, restart your Mac and re open your project, everything should be fine again.

like image 10
JasonSa Avatar answered Nov 18 '22 18:11

JasonSa