Reputation: 7895
I have Xcode 4.2.1 for Lion and it crashes everytime I open anything in a new window (so - for example - double-clicking on any file). In this case, the type doesn't matter. It will crash for .h, .m, .xib, .plist, etc.... I have re-installed Xcode to no avail. This didn't happen until recently - but once it happened once - it keeps happening.
It doesn't appear to have anything to do with the items that are currently open - as I have closed all of them and opened a new project - and I still see the issue.
UPDATE: See my answer below for how I finally got this resolved.
Here is the exception I am getting:
UNCAUGHT EXCEPTION (NSUnknownKeyException): [<__NSCFConstantString 0x7fff7e9e38e0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key file://localhost/Projects/SomeProject/SomeFile.plist.
UserInfo: {
NSTargetObjectUserInfoKey = "";
NSUnknownUserInfoKey = "file://localhost/Projects/SomeProject/SomeFile.plist";
}
Hints: None
Backtrace:
0 0x00007fff979c426a __exceptionPreprocess (in CoreFoundation)
1 0x00007fff983acd5e objc_exception_throw (in libobjc.A.dylib)
2 0x00007fff97a4e4c9 -[NSException raise] (in CoreFoundation)
3 0x00007fff8f9a8783 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] (in Foundation)
4 0x00007fff8f8df462 _NSGetUsingKeyValueGetter (in Foundation)
5 0x00007fff8f8df3e9 -[NSObject(NSKeyValueCoding) valueForKey:] (in Foundation)
6 0x00007fff8f8df101 -[NSArray(NSKeyValueCoding) valueForKey:] (in Foundation)
7 0x000000010a2ced12 -[IDEWorkspaceDocument _defaultPrimaryEditorFrameSizeForDocumentURL:] (in IDEKit)
8 0x000000010a307d62 -[IDEWorkspaceWindowController _changeSizeForSimpleEditorWindowLayoutWithEditorDocumentURLOrNil:workspaceTabController:] (in IDEKit)
9 0x000000010a30827d -[IDEWorkspaceWindowController _revertForNewWindowWithTabStateContext:documentURL:simpleEditorWindowLayout:completionBlock:] (in IDEKit)
10 0x000000010a2cf795 -[IDEWorkspaceDocument _makeTabbedWindowControllerWithStateFromTabController:documentURL:simpleEditorWindowLayout:frontmost:completionBlock:] (in IDEKit)
11 0x000000010a2f4188 +[IDEEditorCoordinator _doOpenIn_NewWindow_withWorkspaceTabController:documentURL:usingBlock:] (in IDEKit)
12 0x000000010a2f4c41 +[IDEEditorCoordinator _doOpenIn_SeparateWindow_withWorkspaceTabController:documentURL:usingBlock:] (in IDEKit)
13 0x000000010a2599ba +[IDEEditorCoordinator _doOpenWithWorkspaceTabController:editorContext:target:allowFallback:documentURL:usingBlock:] (in IDEKit)
14 0x000000010a2f4dd5 +[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:] (in IDEKit)
15 0x000000010a259353 -[_IDEOpenRequest _runIfNecessary] (in IDEKit)
16 0x000000010a258d3a -[_IDEOpenRequest _enqueueForEventBehavior:] (in IDEKit)
17 0x000000010a258855 +[IDEEditorCoordinator _openRequestForEditorOpenSpecifier:workspaceTabController:editorContext:eventBehavior:takeFocus:] (in IDEKit)
18 0x000000010a2587ac __99+[IDEEditorCoordinator _openEditorOpenSpecifier:forWorkspaceTabController:eventBehavior:takeFocus:]_block_invoke_0 (in IDEKit)
19 0x000000010a258740 _performBlockInsideReentrantGuard (in IDEKit)
20 0x000000010a2586b5 +[IDEEditorCoordinator _openEditorOpenSpecifier:forWorkspaceTabController:eventBehavior:takeFocus:] (in IDEKit)
21 0x000000010a25839d +[IDEEditorCoordinator openEditorOpenSpecifier:forWorkspaceTabController:eventType:] (in IDEKit)
22 0x000000010a2579a1 -[IDEOutlineBasedNavigator _openNavigableItem:eventType:] (in IDEKit)
23 0x00007fff979b3a1d -[NSObject performSelector:withObject:] (in CoreFoundation)
24 0x00007fff8df32710 -[NSApplication sendAction:to:from:] (in AppKit)
25 0x0000000109b1fd10 -[DVTApplication sendAction:to:from:] (in DVTKit)
26 0x000000010a207cf4 -[IDEApplication sendAction:to:from:] (in IDEKit)
27 0x00007fff8df32642 -[NSControl sendAction:to:] (in AppKit)
28 0x000000010a25776f -[IDENavigatorOutlineView sendAction:to:] (in IDEKit)
29 0x00007fff8df98f48 -[NSTableView _sendAction:to:row:column:] (in AppKit)
30 0x00007fff8df95d0f -[NSTableView mouseDown:] (in AppKit)
31 0x00007fff8e313592 -[NSOutlineView mouseDown:] (in AppKit)
32 0x000000010a256274 -[IDENavigatorOutlineView mouseDown:] (in IDEKit)
33 0x00007fff8defb0e0 -[NSWindow sendEvent:] (in AppKit)
34 0x00007fff8de9368f -[NSApplication sendEvent:] (in AppKit)
35 0x000000010a207a11 -[IDEApplication sendEvent:] (in IDEKit)
36 0x00007fff8de29682 -[NSApplication run] (in AppKit)
37 0x00007fff8e0a880c NSApplicationMain (in AppKit)
38 0x0000000109901eec (in Xcode)
39 0x0000000000000002
Upvotes: 5
Views: 575
Reputation: 1
Here is how I fixed mine:
Upvotes: 0
Reputation: 7895
The answer for me ended up being a combination of multiple factors. For some reason, Xcode 4.2.x was facilitating the problem. I finally upgraded to Xcode 4.3 - but the problem still occurred. After clearing out the preferences for Xcode (after updating) the problem went away. I tried this numerous times with Xcode 4.2.x - but even clearing the preferences wouldn't solve the problem.
I'm glad to have this resolved - but I don't know how to resolve without upgrading to Xcode 4.3.
Upvotes: 0
Reputation: 813
Just a shot in the dark, does it happen in a new user account?
Upvotes: 0
Reputation: 9896
The stack trace shows an NSArray
object which is sent the valueForKey:
message with the key "file://localhost/Projects/SomeProject/SomeFile.plist"
. This just sends valueForKey:
to each object in the array. One of the objects is an empty NSString
which has just the default NSObject
's implementation of valueForKey:
, which naturally doesn't know anything about the above key (@"file://..."
) so it throws an exception.
The method sending valueForKey:
to the NSArray is
-[IDEWorkspaceDocument _defaultPrimaryEditorFrameSizeForDocumentURL:]
in IDEKit.
So I disassembled this method in IDEKit (/Developer/Library/PrivateFrameworks/IDEKit.framework/Versions/A/IDEKit) using the hopper disassembler.
What I concluded is that this method reads an NSArray from Xcode's [NSUserDefaults standardUserDefault]
, from the key @"IDEDefaultPrimaryEditorFrameSizeForPaths"
. This array is then sent the valueForKey:
with your file's path, hoping to find the frame size for the file's editor but instead causing the error. The problem is probably that somehow this NSUserDefaults
entry became invalid (Either it's an NSArray
with unexpected content, or it's not even supposed to be an NSArray
).
So, there's a good chance clearing Xcode's preferences will help, as suggested by @RAZ :-) (It's not certain it will help, as the user defaults can be registered by Xcode at runtime - but it might).
An alternative (less interesting but pragmatic :-) ) solution is to reinstall Xcode to a location other than the default. When you install, you can choose a custom install folder. This will install a fresh copy of Xcode side by side next to your original.
Upvotes: 2
Reputation: 392
I've been having similar issues in Xcode myself and I'm seeing a few ppl around forums experiencing bugs related to Xcode itself. it might help repairing disk permissions, but I can't really confirm it. but worth the try
Upvotes: 0
Reputation: 577
Reset your simulator, it can cache bad data after an upgrade.
I have also seen people fix misbehaving apps by clearing apps prefs
http://hints.macworld.com/article.php?story=20001229001847541
just backup first, you said you reinstalled but some installers do not reset prefs.
Upvotes: 1