如何让 Xcode 不自动打开以前打开的项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8053418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:22:03  来源:igfitidea点击:

How to Get Xcode to Not Automatically Open Previously Opened Projects

xcode

提问by dtuckernet

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?

所以,我从一个旧项目打开了一个 xib 文件,它导致了崩溃。这不是问题。问题是,现在当我重新启动 Xcode 时,它​​会尝试打开所有以前打开的项目(和文件)并且再次发生崩溃。Xcode 在哪里存储以前打开的文件列表,我怎样才能让它在没有任何打开的项目的情况下开始“干净”?

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

更新:请注意 - 这是 Lion 上最新版本的 Xcode 4.2。

回答by Kay

Press option+Shiftwhen 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.

单击 Dock 中的 Xcode 图标时按option+ Shift。然后 Xcode 启动时不会打开以前使用过的项目。这与版本 4.5.2 (4G2008a) 有关,但我几乎可以肯定我也在旧版本中使用了它。

回答by Dons

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.

我最近遇到了类似的问题。我尝试了上述方法并且可以从命令行启动 Xcode,但是一旦我尝试从 finder 打开,它就会尝试打开“坏”文档并挂起。

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.

这似乎为我修复了它。

回答by pxlshpr

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.

我只是花了半天时间来强调一个非常相似的问题。我曾尝试更新并重新安装 Xcode - 但问题仍然存在。值得庆幸的是,几分钟前,我在这篇文章的帮助下按照您提出的问题设法解决了这个问题。

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

基本上,我使用以下命令从终端打开了另一个 Xcode 项目(但它可以是任何文件):

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!

这成功地启动了 Xcode,并带有您通常会看到的标准“欢迎使用 Xcode”对话框。希望有帮助!

回答by NoelHunter

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

我能够在小牛队中使用以下命令行来做到这一点:

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

回答by erkanyildiz

Not specific to Xcode:

不特定于 Xcode:

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

请确保Close windows when quitting an application选中System Preferences> 下的复选框General

回答by Jon Stokes

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.

对我来说,这不是导致启动时崩溃的项目,而是一个特定的文件(准确地说是 sks),所以 Kay 的回答没有用。当我打开我的特定项目时,它仍然会崩溃。

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

我只是暂时删除了该文件。然后我打开项目,清理并重新添加文件,一切都很好。

回答by Caleb

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

使用以下defaults命令查看设置本身,而不是查找包含 Xcode 设置的文件:

% defaults read com.apple.xcode | more

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

我注意到两个可能相关的键:NSRecentXCFileDocumentsNSRecentXCProjectDocuments。两者似乎都是数组,因此您可以像这样重置一个:

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

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

或者,您可以使用该defaults read命令将设置转储到文本文件中,对其进行编辑,然后用于defaults write更新设置:

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

回答by focused4success

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

给定目录 ~/Documents/Projects/MyProject 中的项目名称“MyProject”,请执行以下操作:

  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
  1. cd ~/Documents/Projects
  2. mv MyProject MyProject.x
  3. open -a Xcode
  4. 关闭我的项目(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.

这为我解决了崩溃……但是我的 Storboard 已损坏。幸运的是,文件夹的 Time Machine 备份完好无损,我刚刚恢复了它。