Why does xCode crash when I open a project?

2019-07-22 12:17发布

问题:

I'm trying to open a project with the latest version of xCode (updated today). For some reason, it crashes. I can't open any project, it crashes all times :( Have you experienced anything similar to this? I've looked at many similar questions, but none of them helped. Crash report begins like this (if helps):

Process:         Xcode [1631]
Path:            /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:      com.apple.dt.Xcode
Version:         5.0.2 (3335.32)
Build Info:      IDEApplication-3335032000000000~4
App Item ID:     497799835
App External ID: 106632651
Code Type:       X86-64 (Native)
Parent Process:  launchd [133]
Responsible:     Xcode [1631]
User ID:         501

Date/Time:       2013-11-12 18:14:14.782 +0100
OS Version:      Mac OS X 10.9 (13A603)
Report Version:  11
Anonymous UUID:  041E96A2-1123-3287-3FF6-A3F30382FC69

Sleep/Wake UUID: C6807823-3147-4602-B01F-A2A9E80B8259

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
ProductBuildVersion: 5A3005
ASSERTION FAILURE in /SourceCache/DVTFoundation/DVTFoundation-3542/Framework/Classes/FileTypes/DVTFileDataType.m:616
Details:  stringRep should be a non-empty string, but it is nil
Object:   <DVTFileDataType>
Method:   +fileDataTypeFromStringRepresentation:
Thread:   <NSThread: 0x7fc7d9d151c0>{name = (null), num = 1}
Hints:   None
Backtrace:
  0  0x0000000102e69ea8 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
  1  0x0000000101bf17a5 _DVTAssertionHandler (in DVTFoundation)
  2  0x0000000101bf1ad4 _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x0000000101b8ca94 +[DVTFileDataType fileDataTypeFromStringRepresentation:] (in DVTFoundation)
  4  0x0000000107fa5dd0 -[Xcode3TargetProduct fileDataType] (in DevToolsCore)
  5  0x00000001025f25ce -[IDEBuildableProductRunnable runnableUTIType:] (in IDEFoundation)
  6  0x00000001025ee340 -[IDEProfileSchemeAction _updateAnalysisToolService] (in IDEFoundation)
  7  0x0000000101c02bc8 __73-[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:]_block_invoke (in DVTFoundation)
  8  0x0000000101c19e88 DVTInvokeWithStrongOwnership (in DVTFoundation)
  9  0x0000000101b58479 -[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:] (in DVTFoundation)
 10  0x00007fff90c4bc18 NSKeyValueNotifyObserver (in Foundation)
 11  0x00007fff90c4ade8 NSKeyValueDidChange (in Foundation)
 12  0x00007fff90c4fa56 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] (in Foundation)
 13  0x0000000102f6b395 -[IDEContextAutocreationController addBuildable:toScheme:] (in IDEKit)
 14  0x0000000102f6bd68 -[IDEContextAutocreationController createSchemeForBuildable:withName:] (in IDEKit)
 15  0x0000000102f6b16d -[IDEContextAutocreationController createDefaultSchemeForBuildable:] (in IDEKit)
 16  0x0000000102cf2976 -[IDEContextAutocreationController autocreateSchemesForcingAutocreate:] (in IDEKit)
 17  0x0000000101c03618 -[NSObject(DVTObservingConvenience) _dvt_newObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 18  0x0000000101b57fc5 -[NSObject(DVTObservingConvenience) dvt_newObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 19  0x0000000101c0326c -[NSObject(DVTObservingConvenience) dvt_addObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 20  0x0000000102f6a11e __53-[IDEContextAutocreationController initForWorkspace:]_block_invoke_2 (in IDEKit)
 21  0x0000000101c03618 -[NSObject(DVTObservingConvenience) _dvt_newObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 22  0x0000000101b57fc5 -[NSObject(DVTObservingConvenience) dvt_newObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 23  0x0000000101c0326c -[NSObject(DVTObservingConvenience) dvt_addObserverForKeyPath:options:owner:withHandlerBlock:] (in DVTFoundation)
 24  0x0000000102f69e8b __53-[IDEContextAutocreationController initForWorkspace:]_block_invoke (in IDEKit)
 25  0x0000000101c02bc8 __73-[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:]_block_invoke (in DVTFoundation)
 26  0x0000000101c19e88 DVTInvokeWithStrongOwnership (in DVTFoundation)
 27  0x0000000101b58479 -[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:] (in DVTFoundation)
 28  0x00007fff90c4bc18 NSKeyValueNotifyObserver (in Foundation)
 29  0x00007fff90c4ade8 NSKeyValueDidChange (in Foundation)
 30  0x00007fff90c4fa56 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] (in Foundation)
 31  0x000000010268481a __81-[IDEWorkspace _finishLoadingAsynchronously:shouldUpgradeFromSimpleFilesFocused:]_block_invoke (in IDEFoundation)
 32  0x0000000102684ac1 __81-[IDEWorkspace _finishLoadingAsynchronously:shouldUpgradeFromSimpleFilesFocused:]_block_invoke281 (in IDEFoundation)
 33  0x00007fff90c6b055 -[NSBlockOperation main] (in Foundation)
 34  0x00007fff90c4a591 -[__NSOperationInternal _start:] (in Foundation)
 35  0x00007fff90c4a23b __NSOQSchedule_f (in Foundation)
 36  0x00007fff852dc2ad _dispatch_client_callout (in libdispatch.dylib)
 37  0x00007fff852e3f03 _dispatch_main_queue_callback_4CF (in libdispatch.dylib)
 38  0x00007fff859b9839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation)
 39  0x00007fff85974b14 __CFRunLoopRun (in CoreFoundation)
 40  0x00007fff85974275 CFRunLoopRunSpecific (in CoreFoundation)
 41  0x00007fff8bc2ef0d RunCurrentEventLoopInMode (in HIToolbox)
 42  0x00007fff8bc2ecb7 ReceiveNextEventCommon (in HIToolbox)
 43  0x00007fff8bc2eabc _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
 44  0x00007fff8b0af28e _DPSNextEvent (in AppKit)
 45  0x00007fff8b0ae8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit)
 46  0x00007fff8b0a29cc -[NSApplication run] (in AppKit)
 47  0x00007fff8b08d803 NSApplicationMain (in AppKit)
 48  0x00007fff899005fd start (in libdyld.dylib)

Thanks in advance!

回答1:

The most common cause of these kinds of crashes is a corrupted DerivedData directory. You can delete this directory (and many of us do this regularly, just to keep things more stable).

  • Open Xcode
  • Preferences
  • Locations
  • The Derived Data option will tell you where your directory is
  • Delete that directory
  • Try to open your project

Personally, I select "Custom" for Derived Data, and put it in /tmp/xcode-build. This deletes the directory every time I reboot, and is easier to type than the default when I want to delete it by hand.


EDIT: One more common problem: you often need to reboot after upgrading Xcode. Since Xcode 5, that's been less of an issue, but it's still worth trying, especially if you're upgrading from Xcode 4.