Xcode 在启动时崩溃可能是由于打开的项目太多

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21203567/
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-15 04:33:59  来源:igfitidea点击:

Xcode crashing on startup possibly due to too many open projects

xcodecrashstartup

提问by Kirby Todd

I just got a new Mac and downloaded Xcode so everything is fresh. On opening Xcode for the first time I accidentally told it to open my src/ folder instead of /src/myLatestProject so my hunch is Xcode went and tried to open every project in my src/ directory (hundreds). It beachballed for a few seconds and then crashed. The issue now is that Xcode seems to have remembered that I want that multitude of projects opened at app startup or it's trying to parse hundreds of git repos and I'm stuck in open/beachball/crash purgatory. How can I reset Xcode's prefs so it won't try to be so helpful and open every bit of source code on my computer?

我刚买了一台新 Mac 并下载了 Xcode,所以一切都很新鲜。第一次打开 Xcode 时,我不小心告诉它打开我的 src/ 文件夹而不是 /src/myLatestProject 所以我的预感是 Xcode 去尝试打开我的 src/ 目录中的每个项目(数百个)。它在沙滩上打了几秒钟,然后坠毁了。现在的问题是 Xcode 似乎记得我希望在应用程序启动时打开大量项目,或者它试图解析数百个 git 存储库而我陷入了开放/沙滩球/崩溃的炼狱。我如何重置 Xcode 的首选项,这样它就不会尝试如此有用并在我的计算机上打开每一个源代码?

EDIT: I've confirmed it's only crashing for my account. If I create a test user and open Xcode, everything is fine.

编辑:我已经确认它只是我的帐户崩溃。如果我创建一个测试用户并打开 Xcode,一切都很好。

 Application Specific Information:
ProductBuildVersion: 5A3005
ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-3575/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/Xcode3Model/Xcode3OCUnitTestableDataSource.m:191
Details:  ([_indexableIdsToTestableTokens objectForKey:indexableIdentifier]) should be nil, but it is <Xcode3OCUnitTestableDataSourceToken: 0x7fe73b531ae0>
Object:   <Xcode3OCUnitTestableDataSource: 0x7fe7359c79f0>
Method:   -setTestableToken:indexableIdentifier:
Thread:   <NSThread: 0x7fe732415570>{name = (null), num = 1}
Hints:   None
Backtrace:
  0  0x0000000109575ea8 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
  1  0x00000001082fc7a5 _DVTAssertionHandler (in DVTFoundation)
  2  0x00000001082fcad4 _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x000000010e8ef3ca -[Xcode3OCUnitTestableDataSource setTestableToken:indexableIdentifier:] (in DevToolsCore)
  4  0x000000010e8f2261 -[Xcode3OCUnitTestableDataSourceToken _initWithDataSource:indexableIdentifier:callbackBlock:] (in DevToolsCore)
  5  0x000000010e8ef87d +[Xcode3OCUnitTestableDataSource testableDataSourceTokenForWorkspace:indexableIdentifier:callbackBlock:] (in DevToolsCore)
  6  0x000000010ea0a464 -[Xcode3OCUnitTestable initWithTarget:] (in DevToolsCore)
  7  0x000000010e9d7b69 -[Xcode3Project _updateTestablesForTargetProxies:] (in DevToolsCore)
  8  0x000000010e9d074d -[Xcode3Project syncTargetProxiesWithProjectTargets] (in DevToolsCore)
  9  0x000000010830e618 -[NSObject(DVTObservingConvenience) _dvt_newObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 10  0x000000010828e5d3 -[NSObject(DVTObservingConvenience) dvt_newObserverForKeyPath:options:withHandlerBlock:] (in DVTFoundation)
 11  0x000000010e9d1815 -[Xcode3Project initWithFilePath:extension:workspace:error:] (in DevToolsCore)
 12  0x0000000108d899ef __73+[IDEContainer retainedContainerAtFilePath:fileDataType:workspace:error:]_block_invoke_2 (in IDEFoundation)
 13  0x00007fff91d9d2ad _dispatch_client_callout (in libdispatch.dylib)
 14  0x00007fff91d9e166 _dispatch_barrier_sync_f_invoke (in libdispatch.dylib)
 15  0x000000010833a0ec DVTSyncPerformBlock (in DVTFoundation)
 16  0x000000010825dfe3 -[DVTDispatchLock performLockedBlock:] (in DVTFoundation)
 17  0x0000000108d893f5 __73+[IDEContainer retainedContainerAtFilePath:fileDataType:workspace:error:]_block_invoke (in IDEFoundation)
 18  0x000000010830f2ed -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation)
 19  0x0000000108cc9579 +[IDEContainer retainedContainerAtFilePath:fileDataType:workspace:error:] (in IDEFoundation)
 20  0x0000000108d9eb40 -[IDEFileReference _recalculateReferencedContainer] (in IDEFoundation)
 21  0x0000000108cdcf48 -[IDEFileReference referencedContainer] (in IDEFoundation)
 22  0x0000000108ce4200 -[IDEContainerQuery _traverseContainerGraphObject:forDeletion:checkedContainers:insertedMatches:deletedMatches:] (in IDEFoundation)
 23  0x0000000108ce617b -[IDEContainerQuery _traverseContainerGraphObjects:forDeletion:insertedMatches:deletedMatches:] (in IDEFoundation)
 24  0x0000000108ce5ec4 -[IDEContainerQuery _objectsDidChange:] (in IDEFoundation)
 25  0x00007fff8d6eefcc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
 26  0x00007fff8d5e2c5d _CFXNotificationPost (in CoreFoundation)
 27  0x00007fff8a3c14aa -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
 28  0x00000001082a7085 -[DVTModelObjectGraph _coalescingTick] (in DVTFoundation)
 29  0x0000000108cd1912 -[IDEGroup _setSubitems:] (in IDEFoundation)
 30  0x0000000108cdee30 -[IDEFolder _updateSubitemsWithFileNames:] (in IDEFoundation)
 31  0x0000000108d8eedb __32-[IDEFolder _filePathDidChange:]_block_invoke94 (in IDEFoundation)
 32  0x0000000108339fdc __DVTAsyncPerformBlock_block_invoke (in DVTFoundation)
 33  0x00007fff8d6517cc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
 34  0x00007fff8d642ee5 __CFRunLoopDoBlocks (in CoreFoundation)
 35  0x00007fff8d64282b __CFRunLoopRun (in CoreFoundation)
 36  0x00007fff8d642275 CFRunLoopRunSpecific (in CoreFoundation)
 37  0x00007fff8b8aef0d RunCurrentEventLoopInMode (in HIToolbox)
 38  0x00007fff8b8aecb7 ReceiveNextEventCommon (in HIToolbox)
 39  0x00007fff8b8aeabc _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
 40  0x00007fff8ad0e28e _DPSNextEvent (in AppKit)
 41  0x00007fff8ad0d8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit)
 42  0x00007fff8ad019cc -[NSApplication run] (in AppKit)
 43  0x00007fff8acec803 NSApplicationMain (in AppKit)
 44  0x00007fff89ff25fd start (in libdyld.dylib)

回答by Kirby Todd

Not sure which one fixed it but I ran the following in terminal and now it works again:

不确定是哪一个修复了它,但我在终端中运行了以下命令,现在它又可以工作了:

cd ~/Library
sudo rm -rf './Preferences/com.apple.dt.Xcode.plist' './Autosave Information/com.apple.dt.Xcode.plist'  './Autosave Information/Unsaved Xcode Document.xcworkspace' './Caches/com.apple.dt.Xcode'

WARNING: Note this may delete other preferences such as key bindings so beware if you have a lot of customization of your xcode environment.

警告:请注意,这可能会删除其他首选项,例如键绑定,因此请注意,如果您对 xcode 环境进行了大量自定义。

回答by Ashutosh

Open finder and go to following path and delete the folders made their, these are the folders made whenever we open any project in xcode temporarily:

打开finder并转到以下路径并删除创建的文件夹,这些是我们临时在xcode中打开任何项目时创建的文件夹:

/Users/MyMac/Library/Developer/Xcode/DerivedData/

回答by dchakarov

On my Xcode6/Yosemite mac there is no "Autosave Information" folder, so I deleted ~/Library/Saved Application State/com.apple.dt.Xcode.savedStatefolder instead and it stopped crashing.

在我的 Xcode6/Yosemite mac 上没有“自动保存信息”文件夹,所以我删除了~/Library/Saved Application State/com.apple.dt.Xcode.savedState文件夹,它停止了崩溃。

回答by Vaidas

If you have any open swift file in a new window (for example when you double click on a .swift file in xCode and it opens in a new window) when xCode opens this might be an issue. I think I had this window opened when closing xCode, then when opening xCode this window opens up again and for some reason crashes xCode. Try to close this open window quickly before it crashes. Strange, but that worked for me.

如果您在新窗口中有任何打开的 swift 文件(例如,当您在 xCode 中双击 .swift 文件并在新窗口中打开时),当 xCode 打开时,这可能是一个问题。我想我在关闭 xCode 时打开了这个窗口,然后在打开 xCode 时这个窗口再次打开并且由于某种原因导致 xCode 崩溃。尝试在它崩溃之前快速关闭这个打开的窗口。奇怪,但这对我有用。

回答by Abhinav Khanduja

You could also do one thing (if you are using pods) :-

您还可以做一件事(如果您使用的是 Pod):-

  1. Right click on your xcworkspace
  2. click on 'Show Package Contents'
  3. Delete xcuserdata folder
  4. relaunch xcode
  1. 右键单击您的 xcworkspace
  2. 点击“显示包裹内容”
  3. 删除 xcuserdata 文件夹
  4. 重新启动 xcode

回答by dMathieuD

The scenario to make Xcode crashing was a bit different on my side. Indeed I had the same callstack error:

使 Xcode 崩溃的情况在我这边有点不同。事实上,我有同样的调用堆栈错误:

Application Specific Information:
ProductBuildVersion: 5A3005
ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-3575/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/Xcode3Model/Xcode3OCUnitTestableDataSource.m:191
Details:  ([_indexableIdsToTestableTokens objectForKey:indexableIdentifier]) should be nil, but it is <Xcode3OCUnitTestableDataSourceToken: 0x7fe73b531ae0>
Object:   <Xcode3OCUnitTestableDataSource: 0x7fe7359c79f0>
Method:   -setTestableToken:indexableIdentifier:
Thread:   <NSThread: 0x7fe732415570>{name = (null), num = 1}
Hints:   None

But I had to duplicate an existing project (.xcodeproj file) in order to have in my workspace an app depending on other projects (Target Dependencies in Build Phases) in my workspace (used as a debug app) and an app not depending on anything only linking to the resulting build output of the corresponding projects target (in my case frameworks inside Link Binary With Libraries in Build Phases). The issue was that each time I imported the duplicated project to my workspace it crashed Xcode... As the crash stack trace was talking about test things I just went through the project.pbxproj and removed all occurrences of test string in that file (well I tool care about section to avoid corrupting my file).

但是我必须复制一个现有项目(.xcodeproj 文件),以便在我的工作区中拥有一个依赖于其他项目(构建阶段中的目标依赖项)的应用程序(用作调试应用程序)和一个不依赖任何内容的应用程序仅链接到相应项目目标的生成构建输出(在我的情况下,链接二进制与构建阶段中的库中的框架)。问题是,每次我将重复的项目导入到我的工作区时,它都会使 Xcode 崩溃......由于崩溃堆栈跟踪正在谈论测试内容,我只是通过 project.pbxproj 并删除了该文件中所有出现的测试字符串(好吧我工具关心部分以避免损坏我的文件)。

Something was going wrong with the duplicated xctest target inside the prject. Once I tried again to import it again in my workspace it worked fine.

项目中重复的 xctest 目标出现问题。一旦我再次尝试在我的工作区中再次导入它,它就可以正常工作。

Hope it can help

希望它可以帮助

回答by Kevin ABRIOUX

I have removed entirely the folder Library/Developer : Close XCode

我已经完全删除了文件夹 Library/Developer :关闭 XCode

rm -r /Library/Developer

And say yes for every files

并对每个文件说是

enter image description here

在此处输入图片说明

回答by Rakesh

No solution worked for me in case you have workspace . But i found out one ..

如果您有工作区,则没有解决方案对我有用。但我发现了一个..

  • delete workspace file if you have one . install pod again using "pod install" in terminal (need to move to your project folder).

  • open workspace again .. and it will solve this issue

  • 如果您有工作区文件,请删除工作区文件。在终端中使用“pod install”再次安装 pod(需要移动到您的项目文件夹)。

  • 再次打开工作区.. 它将解决这个问题