dtuckernet
dtuckernet

Reputation: 7895

How to Get Xcode to Not Automatically Open Previously Opened Projects

So, I opened a xib file from an older project and it caused a crash. That's not the issue. The issue is that now when I restart Xcode, it tries to open all previously opened projects (and files) and the crash re-occurs. Where does Xcode store the list of previously open files, and how can I get it to start 'clean' without any open projects?

Update: As a note - this is the latest version of Xcode 4.2 on Lion.

Upvotes: 92

Views: 26895

Answers (9)

Allan Spreys
Allan Spreys

Reputation: 5707

You can stop Xcode from opening the last project by running the following command:

defaults write com.apple.dt.Xcode ApplePersistenceIgnoreState -bool YES

This and other useful commands are here.

Upvotes: 27

erkanyildiz
erkanyildiz

Reputation: 13234

Not specific to Xcode:

Please make sure Close windows when quitting an application checkbox is checked under System Preferences > General.

Upvotes: 11

Kay
Kay

Reputation: 13146

Press option+Shift when clicking on the Xcode icon in the dock. Xcode then starts without opening previously used projects. This is related to version Version 4.5.2 (4G2008a) but I am almost sure that I used it in older versions as well.

Upvotes: 164

Jon Stokes
Jon Stokes

Reputation: 41

For me it wasn't a project that was causing the crash on startup, it was a particular file (an sks to be exact), so Kay's answer didn't work. When I went to open my particular project, it would still crash.

I simply temporarily deleted the file. Then I opened the project, cleaned, and re-added the file, and all was well.

Upvotes: 1

focused4success
focused4success

Reputation: 433

Given the project name "MyProject" in directory ~/Documents/Projects/MyProject do the following:

  1. cd ~/Documents/Projects
  2. mv MyProject MyProject.x
  3. open -a Xcode
  4. close MyProject (Option+Command+W)
  5. mv MyProject.x MyProject
  6. open -a Xcode

The this solved the crash for me... however my Storboard was corrupt. Fortunately the Time Machine backup of the folder was intact, I just restored it.

Upvotes: 1

NoelHunter
NoelHunter

Reputation: 1006

I was able to do it with the following command line in Mavericks:

open -a /Applications/Xcode.app --args -ApplePersistenceIgnoreState YES

Upvotes: 13

pxlshpr
pxlshpr

Reputation: 1111

I just spent half the day stressing over a very similar issue. I had tried updating and reinstalling Xcode - but the problem still persisted. Thankfully, a few minutes ago, I managed to solve this by doing what your question states with the help of this post.

Basically, I opened another Xcode project (it can be any file, though) from the terminal using the following command:

open -a /Applications/Xcode.app app.xcodeproj/ --args -ApplePersistenceIgnoreState YES

This successfully launched Xcode with the standard 'Welcome to Xcode' dialog box you usually get. Hope that helps!

Upvotes: 31

Dons
Dons

Reputation: 434

I've recently had a similar problem. I tried the methods above and could launch Xcode from the command line, but as soon as I tried to open from the finder, it would try to open the "bad" document and hang.

I eventually resolved it by removing the contents of :

~/Library/Autosave Information/
~/Library/Saved Application State/com.apple.dt.Xcode.savedState

This seems to have fixed it for me.

Upvotes: 38

Caleb
Caleb

Reputation: 125007

Instead of looking for the file that contains Xcode's settings, take a look at the settings themselves using the defaults command:

% defaults read com.apple.xcode | more

I notice two keys that might be relevant: NSRecentXCFileDocuments and NSRecentXCProjectDocuments. Both appear to be arrays, so you could reset one like this:

% defaults write com.apple.xcode NSRecentXCFileDocuments -array ""

Alternately, you could use the defaults read command to dump the settings into a text file, edit that, and then use defaults write to update the settings:

% defaults read com.apple.xcode > xcsettings.plist
// edit xcsettins.plist with your favorite editor
% defaults write com.apple.xcode < xcsettings.plist

Upvotes: 1

Related Questions