ios 加载项目时 Xcode 在启动时冻结
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11247008/
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
Xcode freezes on startup while loading project
提问by BenHedges
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:
我在新的 Macbook Retina 上运行 Xcode 4.3.3 并且出乎意料地 Xcode 在启动后立即开始冻结。我正在处理两个项目,所以当 Xcode 启动时,它会立即启动我正在处理的两个项目。第一个有时加载,但第二个总是冻结。由于项目立即启动,我无法访问 Xcode 的任何功能。我什至不知道如何阻止项目在启动时启动。这是我迄今为止所做的:
- Rebooted comp - still launches projects and freezes
- Deleted everything in cache ~/Library/Developer/Xcode/DerivedData - still launches projects and freezes
- Uninstalled Xcode (hold click in Launchpad, click the (x)). Reinstalled Xcode. - Still launches the projects and freezes
- Moved my projects from original folder - Still launches the projects and freezes
- Created a new iOS user2 and launched Xcode - does NOT launch projects OR freeze yay!
- 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.
- 重新启动的 comp - 仍然启动项目并冻结
- 删除了缓存中的所有内容 ~/Library/Developer/Xcode/DerivedData - 仍然启动项目并冻结
- 卸载的 Xcode(在 Launchpad 中按住单击,单击 (x))。重新安装了Xcode。- 仍然启动项目并冻结
- 将我的项目从原始文件夹中移动 - 仍然启动项目并冻结
- 创建了一个新的 iOS user2 并启动了 Xcode - 不启动项目或冻结耶!
- 在用户 1 中将冻结项目复制到外部,以用户 2 身份登录,启动项目 - 不会冻结!但是现在我需要将我的 Xcode 配置文件和证书转移给新用户。
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).
那么到底发生了什么?我更喜欢使用 User1 并希望实际解决问题,这样如果再次发生,我就不需要创建新用户。(用户 n+1,无限期不是一个有吸引力的选择)。
回答by jhabbott
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.
通过不恢复来恢复理智
感谢 Lion 的恢复功能,当您重新启动给定应用程序时,您在给定应用程序中保持打开的所有窗口都保持打开状态。这在 Web 浏览器或文本编辑器中非常有用。然而,在某些应用程序中——尤其是那些你很少需要重新访问相同文档的应用程序——该功能更令人烦恼。窗口恢复实际上是在逐个应用程序的基础上配置的。以下是在 Preview 和 QuickTime Player X 中禁用恢复的终端命令:
defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false defaults write com.apple.QuickTimePlayerX NSQuitAlwaysKeepsWindows -bool false
在尝试命令之前退出应用程序。同样,将“true”替换为“false”以反转您的更改。
You may be able to do something similar for Xcode.
您也许可以为 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.
否则,您可以option
在按下 键的同时按住 键退出 Lion 中的应用程序并放弃之前打开的窗口CMD+Q
。因此,您可以尝试启动 Xcode 并在它有机会打开您的窗口之前使用选项退出它,然后重新启动它并且它不应该尝试打开窗口。然后您可以尝试解决问题。
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.
这些目录存储诸如窗口位置、打开的文件、展开的项目组等内容。所以一个原因可能是如果您在多台具有相同用户名的机器上使用源代码管理并且这些文件不会被忽略(它们应该如果您使用的是源代码管理,则为)。Retina 与非 Retina 或不同版本的 Xcode 可能会以不同的方式使用这些文件,并且源代码控制合并可能会使它们不一致。因此,请确保在源代码管理中删除并忽略这些目录,以免重新添加它们并再次导致问题。
回答by Montas
What fixed this for me was removing unsaved document in ~/Library/Autosave Information
. After Xcode launched without any problem.
为我解决这个问题的是删除~/Library/Autosave Information
. Xcode启动后没有任何问题。
回答by iVader
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.
我遇到的一个问题:当我将 casetagram 库添加到我的项目中时,在 Xcode 启动几秒钟后,在索引文件之前(我认为),它已经冻结了。在简单地以其他名称重命名文件夹并将其重命名后 - Xcode 再次冻结。
My solution:
我的解决方案:
- Command-Option-Shift-K to clean out the build folder.
- quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData manually
- Command-Option-Shift-K 清除构建文件夹。
- 退出 Xcode 并手动清理 ~/Library/Developer/Xcode/DerivedData
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).
如果您在 Xcode 被冻结之前还有一段时间:您必须启动 Xcode,然后快速打开 Organizer->Projects 并从列表中删除您的项目(项目,Xcode 冻结的项目)。
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
如果您没有足够的时间打开管理器,那么: 1) 退出 Xcode。2)重命名项目所在的文件夹。然后执行解决方案的 1 变体(打开管理器并删除将冻结 Xcode 的项目)3)重命名您的文件夹
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
如果所有这些操作后 Xcode 会冻结,请尝试打开其他项目并编译它。如果可行,请返回并尝试构建 Xcode 冻结的项目。如果 Xcode 再次被冻结,那么在这个具体项目中的原因
回答by VSB
Using answer in apple.stackexchange.comdid the trick for me:
在apple.stackexchange.com 中使用 answer对我有用:
Removing the
~/Library/Saved Application State/com.apple.dt.Xcode.savedState/
directory might help.
删除
~/Library/Saved Application State/com.apple.dt.Xcode.savedState/
目录可能会有所帮助。
If this did not work, then remove
~/Library/Developer
(brought from hereand here)
回答by Alexey Starchikhin
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.
我不小心双击了 Xcode 打开项目对话框中的 Projects 文件夹,它试图一次打开所有项目,然后冻结了。这个分支的建议没有帮助,但经过一些搜索我找到了应该删除的文件。找到 current_user/Libraries/Autosave Information 并从那里删除所有与 Xcode 相关的内容,这应该会有所帮助。
回答by coder
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.
我今天遇到了同样的问题,在视网膜显示屏 MacBook Pro 上运行相同的 Xcode 4.3.3 配置。我通读了这个页面,并决定首先尝试删除 jhabbott 上面列出的文件:MyProject.xcodeproj/xcuserdata 和 MyProject.xcodeproj/project.xcworkspace/xcuserdata 目录。那奏效了。删除文件后,我可以启动 Xcode,然后通过选择File > Open 最近打开我的项目。如果按住命令键并单击项目文件,然后从菜单中选择Show Package Contents,则可以直接从 Finder 中删除这些项目。
回答by Ian
I fixed this condition by renaming the root directory that contains all the Xcode projects.
我通过重命名包含所有 Xcode 项目的根目录来解决这个问题。
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.
当 Xcode 未运行时,重命名目录,然后启动 Xcode。Xcode 将无法找到这些项目,并且会默默地忽略它们。退出 Xcode,将目录恢复为原始名称,然后再次启动 Xcode。它不应该尝试在启动时加载项目。
Not sure why this works but your step #4 (moving the projects) does not.
不知道为什么这有效,但您的第 4 步(移动项目)无效。
回答by JasonSa
Open your project and then right click on yourprojectname.xcodeproj
then click on Show package contents
.
打开您的项目,然后右键单击,yourprojectname.xcodeproj
然后单击Show package contents
。
There you're going to see the xcuserdata
. Delete it.
在那里你会看到xcuserdata
. 删除它。
Next, right click in project.xcworkspace
, click on Show package contents
and delete the xcurserdata
.
接下来,右键单击project.xcworkspace
,单击Show package contents
并删除xcurserdata
。
At the end, restart your Mac and re open your project, everything should be fine again.
最后,重新启动您的 Mac 并重新打开您的项目,一切都会再次正常。
回答by Charlton Provatas
For me the issue was actually iCloud Drive syncing files at the same time Xcode was trying to access them.
对我来说,问题实际上是在 Xcode 尝试访问它们的同时 iCloud Drive 同步文件。
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)
我能够通过将项目复制到未由 iCloud Drive 同步的目录来解决该问题(使用cp
命令,而不是 Finder)
回答by Zohar Chiprut
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.
重新启动Mac后发生在我身上。也许有些东西没有正确保存,在 Xcode 上电后仍然“没有响应”。我重命名了我打开的最后一个项目的根目录。当打开 Xcode 而不是堆栈时,它会打开并响应找不到项目的错误。然后我只是定期打开该项目,它运行良好。