BenHedges
BenHedges

Reputation: 393

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

Upvotes: 36

Views: 47087

Answers (18)

PMC
PMC

Reputation: 11

Keep Xcode in Dock. Then Force Quit. Option + Shift then click on Xcode on the Docker. That solved it for me.

Upvotes: 0

Cue
Cue

Reputation: 3092

The problem could be due to a bad internet connection: probably Xcode when opening the project, is waiting to receive or trying to send, information that does not arrive. Try launching your project after temporarily disabling Wi-Fi on your Mac. Or switching networks to one you know is more stable.

Upvotes: 0

Ralek
Ralek

Reputation: 1

Nothing worked for me until I realised my project file was synced to iCloud. This was causing some files to not be on my local machine and preventing Xcode from starting.

If none of the above solutions work, then try adding ".nosync" to the end of your workspace folder name. Wait a few minutes until the cloud icon disappears, indicating that all files are on your device. Then Xcode should work perfectly.

Upvotes: 0

Tornike Gomareli
Tornike Gomareli

Reputation: 1709

I tried everything and nothing helped. Lost already 3 hours while trying to solve this issue.

What helped and solved everything was to run this in my terminal

defaults delete com.apple.dt.Xcode

Upvotes: 7

samonthego
samonthego

Reputation: 61

To open Xcode without it automatically loading the last project, hold Shift-option while picking the icon from the dock. This helped me bypass the 'bad project' and troubleshoot from the IDE.

Upvotes: 6

ZachtheBoB
ZachtheBoB

Reputation: 400

If anyone is still having this issue, if your project is in iCloud drive, this can cause an issue with the syncing. By moving it outside of the drive, it fixes the problem. (For me at least, I tried everything else)

Upvotes: 3

Ross
Ross

Reputation: 141

Its silly but after trying all solutions I found the apple icloud was trying to backup my repos from my documents to the cloud and run it from there causing very slow load times and freezes - make sure your repos are located outside of icloud folders or just disable it.

Upvotes: 14

Zohar Chiprut
Zohar Chiprut

Reputation: 908

It happened to me after restarting the Mac. Maybe something not saved properly and after power up Xcode remained "not responding". I renamed the root of the last project I opened. When opened Xcode instead of being stack it opened and response with error that it couldn't find the project. Then I jsust opened the project regularly and it worked fine.

Upvotes: 0

Charlton Provatas
Charlton Provatas

Reputation: 2274

For me the issue was actually iCloud Drive syncing files at the same time Xcode was trying to access them.

I was able to fix the issue by copying the project to a directory that was not synced by iCloud Drive (using cp command, not Finder)

Upvotes: 1

VSB
VSB

Reputation: 10375

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)

Upvotes: 31

JasonSa
JasonSa

Reputation: 131

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.

Upvotes: 13

iVader
iVader

Reputation: 212

A problem which I had: When I added a casetagram library into my project, then a few seconds after launch of Xcode, before indexing of files (as I think), it had become freezes. After simply rename folder on other name and rename it back - Xcode freezes again.

My solution:

  1. Command-Option-Shift-K to clean out the build folder.
  2. quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData manually

Then:

If you have some time before Xcode will be frozen: You must launch Xcode, then quickly open Organizer->Projects and remove your project from list (project, on which Xcode freezes).

If you haven't enough time for open of organiser then: 1) quit from Xcode. 2) rename folder where your project is located. Then perform the 1 variant of solution (open organizer and remove project on which Xcode will be frozen) 3) rename your folder back

If Xcode will frozen after all of this actions, try to open other project and compile it. If it works, go back and try build your project on which Xcode was frozen. If Xcode again will be frozen then reason of it at this concrete project

Upvotes: 5

CpnCrunch
CpnCrunch

Reputation: 5061

You just need to remove these directories:

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

As jhabbott says, these directories store the locations of open files, windows, etc. and can be safely deleted. Generally the issue is that you have a reference in the xcuserdata to an old network share that doesn't exist any more, and xcode sits there for a long time trying to access it.

Make sure you delete these directories for all your XCode projects.

Upvotes: 0

jhabbott
jhabbott

Reputation: 19281

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.

Upvotes: 46

Montas
Montas

Reputation: 694

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

Upvotes: 35

Alexey Starchikhin
Alexey Starchikhin

Reputation: 71

I accidentally double-clicked on Projects folder in Xcode Open project dialog, it tried to open all projects at once, and freezed. Advices from this branch did't help, but after some searching i found the files, that should be deleted. Locate current_user/Libraries/Autosave Information and delete all Xcode-related from there, that should help.

Upvotes: 7

coder
coder

Reputation: 41

I experienced the same problem today, with the same configuration of Xcode 4.3.3 running on a retina display MacBook Pro. I read through this page, and decided to first try deleting the files listed above by jhabbott: MyProject.xcodeproj/xcuserdata and MyProject.xcodeproj/project.xcworkspace/xcuserdata directories. That worked. After deleting the files I was able to start Xcode and then open my project by selecting File > Open Recent. You can delete those items directly from Finder if you hold down the command key and click on the project file, and then from the menu choose Show Package Contents.

Upvotes: 4

Ian
Ian

Reputation: 111

I fixed this condition by renaming the root directory that contains all the Xcode projects.

While Xcode is not running, rename the directory, then start Xcode. Xcode won't be able to find the projects and will silently ignore them. Quit Xcode, revert the directory back to the original name, and start Xcode again. It should not try to load the projects at startup.

Not sure why this works but your step #4 (moving the projects) does not.

Upvotes: 3

Related Questions