打开项目文件时 Xcode 崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4455903/
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 Crashing When Opening Project File
提问by Sheehan Alam
Xcode keeps crashing on me when I open my project file. I've been able to open it fine for weeks now. Not sure how to diagnose. It only crashes for a specific project.
当我打开我的项目文件时,Xcode 一直在我身上崩溃。我已经能够打开它好几个星期了。不知道如何诊断。它只会因特定项目而崩溃。
Process: Xcode [1293]
Path: /Developer/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.Xcode
Version: 3.2.5 (1760)
Build Info: DevToolsIDE-17600000~5
Code Type: X86-64 (Native)
Parent Process: launchd [189]
Date/Time: 2010-12-15 16:05:24.659 -0700
OS Version: Mac OS X 10.6.5 (10H574)
Report Version: 6
Interval Since Last Report: 201 sec
Crashes Since Last Report: 4
Per-App Interval Since Last Report: 80 sec
Per-App Crashes Since Last Report: 4
Anonymous UUID: 2B7F7CFC-45EA-450C-8467-6BF1E356B6F6
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000025940
Crashed Thread: 10 Dispatch queue: com.apple.Xcode.index-access
Application Specific Information:
objc[1293]: garbage collection is ON
回答by Kendall Helmstetter Gelner
The crash is generally a sign the project file has been corrupted. Here's a list of possible things you can do to try to fix it.
崩溃通常是项目文件已损坏的标志。这是您可以尝试修复它的可能操作列表。
1. Fix a corrupted *.pbxproj
file
1.修复损坏的*.pbxproj
文件
Caused by a merge conflict
由合并冲突引起
If you are using version control, it might be caused by a merge conflict that has not yet been resolved.
如果您使用的是版本控制,则可能是由尚未解决的合并冲突引起的。
- Using Finder, open the directory that holds your project.
- Right click the project file
YOUR_PROJECT_NAME.xcodeproj
andOpen With
your preferred text editing tool such as Sublime Text. - Look for merge conflicts which are usually marked using a series of
=========
bars. - Resolve the merge conflicts manually or remove the changes of one side.
- 使用 Finder 打开保存项目的目录。
- 右键单击项目文件
YOUR_PROJECT_NAME.xcodeproj
和Open With
您喜欢的文本编辑工具,例如 Sublime Text。 - 查找通常使用一系列
=========
条标记的合并冲突。 - 手动解决合并冲突或删除一侧的更改。
Caused by unreadable XML
由不可读的 XML 引起
If that fails go into the file and quickly scroll through to see if anything seems out of place - it should generally be readable XML. You could even try an XML validator against it to see if anything amiss was found.
如果失败进入文件并快速滚动查看是否有任何不合适的地方 - 它通常应该是可读的 XML。您甚至可以针对它尝试使用 XML 验证器来查看是否发现了任何错误。
2. Reset your workspace
2. 重置您的工作区
- Using Finder, open the directory that holds yor project.
- Right click the project file
MyProject.xcodeproj
and chooseShow Package Contents
. - Delete the
xcuserdata
folder, which should contain a folder with your username on it. - Repeats step 2 and 3 for your workspace file
MyProject.workspace
- 使用 Finder,打开您的项目所在的目录。
- 右键单击项目文件
MyProject.xcodeproj
并选择Show Package Contents
. - 删除
xcuserdata
文件夹,其中应该包含一个带有您的用户名的文件夹。 - 对您的工作区文件重复步骤 2 和 3
MyProject.workspace
As elaborated by KennyWinkerand Paul Ron the answers below.
正如KennyWinker和Paul R在下面的答案中所阐述的那样。
3. Recreate your Xcode project
3. 重新创建你的 Xcode 项目
Note that this should be your last resort as it is quite tedious to do for large projects.
请注意,这应该是您最后的手段,因为对于大型项目来说这样做非常乏味。
Lastly you could simply re-create it. That might seem like a big pain, but basically you could just create a new project and drag everything under the "Classes" folder into Xcode to start using it (don't forget to also add the frameworks you need).
最后,您可以简单地重新创建它。这可能看起来很痛苦,但基本上你可以创建一个新项目并将“Classes”文件夹下的所有内容拖到 Xcode 中以开始使用它(不要忘记添加你需要的框架)。
回答by Kenny Winker
Just wanted to elucidate on @Paul R's comment.
只是想阐明@Paul R 的评论。
I had a situation where Xcode was crashing every time I opened a project file. It seemed to be connect to the IB window that was opening. In the end it was deleting the contents of MyProject.xcodeproj/project.xcworkspace/xcuserdata/
that solved this. It did this by resetting the workspace (open files, window scaling, etc.)
我遇到过每次打开项目文件时 Xcode 都会崩溃的情况。它似乎连接到正在打开的 IB 窗口。最后它删除了MyProject.xcodeproj/project.xcworkspace/xcuserdata/
解决这个问题的内容。它通过重置工作区(打开文件、窗口缩放等)来实现这一点。
Hope this is helpful.
希望这是有帮助的。
回答by Shobhit Puri
What worked for me?
什么对我有用?
The only solution that worked for me was deleting the derived data folders of the hanging project, i.e the derived data folders in above directory: ~/Library/Developer/Xcode/DerivedData/
. Hope it helps someone.
唯一对我有用的解决方案是删除挂起项目的派生数据文件夹,即上述目录中的派生数据文件夹:~/Library/Developer/Xcode/DerivedData/
. 希望它可以帮助某人。
What didn't?
什么没有?
As mentioned at other places, deleting MyProject.xcodeproj/project.xcworkspace/xcuserdata/
or MyProject.xcodeproj/xcuserdata/
didn't work for me.
正如在其他地方提到的,删除MyProject.xcodeproj/project.xcworkspace/xcuserdata/
或MyProject.xcodeproj/xcuserdata/
对我不起作用。
回答by valbu17
Just wanted add some extra content to @Kenny Winker answer...
只是想在@Kenny Winker 的回答中添加一些额外的内容...
To delete your xcode user data go,
要删除您的 xcode 用户数据,请执行以下操作:
- Find your Xcode project file ex:
MyProject.xcodeproj
orMyProject.xcworkspace
- Right click on it and choose
Show Package Contents
- Finally, just delete everything inside the folder
xcuserdata
- Done! :)
- 找到您的 Xcode 项目文件,例如:
MyProject.xcodeproj
或MyProject.xcworkspace
- 右键单击它并选择
Show Package Contents
- 最后,只需删除文件夹内的所有内容
xcuserdata
- 完毕!:)
Hopefully, this adds a bit more context to people who doesn't know where to find their project user data.
希望这能为那些不知道在哪里可以找到他们的项目用户数据的人增加更多的背景信息。
回答by Jayprakash Dubey
I had similar problem with Xcode 8.1. The reason maybe the project file contains merge conflict data.
You can remove this by opening Xcode project file in TextEdit.
我在 Xcode 8.1 上遇到了类似的问题。原因可能是project file contains merge conflict data.
您可以通过以下方式删除它opening Xcode project file in TextEdit.
However, in my case there was no merge conflict. Simply deleting content of DerivedData worked for me.
但是,就我而言,没有合并冲突。简单地删除 DerivedData 的内容对我有用。
Steps :
Steps :
- Open finder window then select
Go Tab -> Go to Folder… (or press Cmd + shift + G)
- 打开finder窗口然后选择
Go Tab -> Go to Folder… (or press Cmd + shift + G)
- Enter
~/Library
and pressGo
. This opens Library folder which is hidden by default.
- 输入
~/Library
并按Go
。这将打开默认隐藏的库文件夹。
- Go to
Developer -> Xcode -> DerivedData
folder.Delete all the content of this folder.
The DerivedData is like cache i.e. create every time you build/run your app.
- 转到
Developer -> Xcode -> DerivedData
文件夹。Delete all the content of this folder.
DerivedData 就像缓存,即每次构建/运行应用程序时都会创建。
- Now open the project. It should work with no issues.
- 现在打开项目。它应该可以正常工作。
回答by Desert Rose
Copying Answer of @Sean D which worked for me.
复制对我有用的@Sean D 的答案。
After seeing a suggestion here, I solved this issue by deleting Xcode's preferences. The most reliable way to do that is the following terminal command, issued after quitting Xcode:
在这里看到一个建议后,我通过删除 Xcode 的首选项解决了这个问题。最可靠的方法是在退出 Xcode 后发出以下终端命令:
defaults delete com.apple.dt.Xcode
ETA: Other suggestions have involved changing or removing certain individual preference settings, but after trying a few of those, none worked for me. There seem to be multiple incompatibilities in the preferences between 6 and 7b3, so trashing the prefs entirely should work around them all.
ETA:其他建议涉及更改或删除某些个人偏好设置,但在尝试了其中的一些之后,没有一个对我有用。6 和 7b3 之间的首选项似乎存在多种不兼容,因此完全删除首选项应该可以解决所有问题。
回答by zeeawan
Computer restart
电脑重启
workedfor me. While
工作对我来说。尽管
xcuserdata deletion
and
和
defaults delete com.apple.dt.Xcode
didn't workfor me.
对我不起作用。
I even was not able to open xcode alone or any of my projects or single .m file.
我什至无法单独打开 xcode 或我的任何项目或单个 .m 文件。
回答by Morten J
I had XCode crashing every time I opened Images.xcassets. The solution was to delete a corrupt PDF file I had just added.
每次打开 Images.xcassets 时,XCode 都会崩溃。解决方案是删除我刚刚添加的损坏的 PDF 文件。
回答by Nathan Hangen
Same thing happened to me, and it was some sort of versioning issue that I couldn't fix, so I reverted back to a prior version and it worked. Feels like there are a few bugs in XCode 4 that still need to be worked out.
同样的事情发生在我身上,这是我无法修复的某种版本控制问题,所以我恢复到以前的版本并且它起作用了。感觉 XCode 4 中还有一些错误需要解决。
回答by Ankit Sharma
I was also facing same issue, everytime xcode was crashing. i restarted mac, cleared derived data/xcuserdata but nothing worked.
我也面临同样的问题,每次 xcode 崩溃时。我重新启动了 mac,清除了派生数据/xcuserdata,但没有任何效果。
I had one more repo so i copied 'project.xcodeproj' file from there and paste it in current repo, this trick resolved my problem.
我还有一个 repo,所以我从那里复制了“project.xcodeproj”文件并将其粘贴到当前 repo 中,这个技巧解决了我的问题。