How to turn off reopen projects on Xcode launch In Xcode 4.1 & later

ε祈祈猫儿з 提交于 2019-11-27 03:11:06

问题


In Xcode 4.1 to present (4.2.1), if I close Xcode without first closing the project, the project will be automatically reopened the next time I launch Xcode. Previously I would have gotten the Welcome Screen. Is there a way to change this so that the Welcome Screen is launched instead?


回答1:


I did not have this trouble after disabling the 'Restore windows when quitting and re-opening apps' in the System Preferences.

System Preferences -> General -> Number of recent items section

Here you can find a checkbox to disable the feature.

However, if you force quit X-code, it will try and launch the projects that were open. Hope this helps.




回答2:


Don't want Xcode to second guess you so much?

I found an Xcode specific fix on Daniel Tull's blog, he credited it to "Pete". The link to his blog below describes doing the same task from the Finder.

XCode stores its prior window state here when it quits:

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

If you empty that folder and lock it, when you quit Xcode, it cannot write into the folder, but will simply quit gracefully. Subsequently, if you start Xcode directly, it opens nothing; Double clicking on a project file will open ONLY that project. It's exactly the behavior i want, and other apps will still obey the 'Restore windows when quitting and re-opening apps' General Preference.

I assume this trick would work selectively for other apps which use the "Saved Application State" folder, though some might complain if they can't write their state on the way out. You can probably accomplish this using unix permissions as well, but I only tested it using HFS locking on Lion with Xcode432.

Here are shell commands to this all in one go, set to be verbose and timid while doing so. You can just paste the whole block into a command terminal. This should work fine even if Xcode is running, but since Xcode4 swoons away on the flimsiest excuse, it's probably better to quit it first.

#----------
#show the current contents:
ls -al ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState/*
#just in case, unlock the folder, using the HFS-specific lock mechanism:
chflags -vv nouchg ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
#Empty the folder, asking for permission on each file (type 'y', then <enter> for each)
rm -ivd ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState/*
# Finally lock the folder so Xcode can't save its window state in the future:
chflags -vv uchg ~/Library/Saved\ Application\ State/com.apple.dt.Xcode.savedState
# ----------

http://danieltull.co.uk/blog/2011/11/07/preventing-xcode-4-on-lion-reopening-windows/




回答3:


Short version: ⌥⌘Q.

Pressing the option/alt key (AKA ⌥) when you quit does the trick. From the keyboard, ⌥⌘Q. From the menu, ⌥ changes "Quit Xcode" to "Quit And Discard Windows".

I still wish I knew a setting to do this by default (or better, reverse it, so ⌥ would cause Xcode to "Quit and Keep Windows"). For nefarious rejiggering, I also looked for "Quit And Discard Windows" under Xcode key bindings; no luck.




回答4:


For Xcode Version 6.3 (6D570)

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



来源:https://stackoverflow.com/questions/6920158/how-to-turn-off-reopen-projects-on-xcode-launch-in-xcode-4-1-later

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!