Xcode Interface Builder crashes when I edit storyb

2019-01-15 18:01发布

问题:

I'm new to Xcode and am having problems with the IDE crashing when I use the Interface Builder. This is Xcode 4.5.

It worked properly for long enough for me to add a dozen or so buttons to the storyboard -- but when I try to resize any of them, it crashes and quits. If I move a button, it crashes. If I add a new object like a label, it sometimes crashes, but not always.

If I don't try to edit the storyboard, the project builds and runs on the simulator with no problems.

I've pasted what looks like the relevant part of the crash report below. To save space, I've deleted everything from the 'view hierarchy' section downwards, but I can add it if it's useful. All the crash reports refer to the same error.

Interestingly, when I look at the Console log, there's another report from Interface Builder before each of these crashes:

25/09/2012 10:46:35.661 Interface Builder Cocoa Touch Tool: CFPreferences:
user home directory at file://localhost/Users/me/Library/Application Support/
iPhone Simulator/User/ is unavailable. User domains will be volatile.

It's correct -- that directory doesn't exist. I've got iPhone Simulator/6.0, but nothing else. I'm logged in as the user in that path.

Based on other suggestions on Stack Overflow and elsewhere, I've tried cleaning the build then deleting the entire iPhone Simulator directory and letting the simulator recreate it, but that makes no difference.

As an experiment, I've just created a new Project and dragged some buttons and labels into the storyboard. That seems fine. No crashes.

Does that suggest that something has got corrupted in my other project?

Any suggestions would be very welcome. This is not an important project -- I'm learning my way around at this stage -- but if something is causing problems then I want to sort it out before I start any serious work in Xcode.

Thanks in advance.

James

Process:         Xcode [650]
Path:            /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:      com.apple.dt.Xcode
Version:         4.5 (1839)
Build Info:      IDEApplication-1839000000000000~3
App Item ID:     497799835
App External ID: 10747437
Code Type:       X86-64 (Native)
Parent Process:  launchd [129]

Date/Time:       2012-09-25 10:46:43.202 +0100
OS Version:      Mac OS X 10.7.5 (11G56)
Report Version:  9

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

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

Application Specific Information:
ProductBuildVersion: 4G182
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilderCocoaTouch/IDEInterfaceBuilderCocoaTouch-1926/IBPlugin/Utilities/IBObjectMarshalling.m:651
Details:  Failed to arbitrate IBNSLayoutConstraint, IBUIButton, IBUILabel, IBUIView, and IBUIViewController.

Interface Builder encountered an error communicating with the iOS Simulator. If you choose to file a crash report or radar for this issue, please check Console.app for crash reports for "Interface Builder Cocoa Touch Tool" and include their content in your crash report.

Exception name: IBAssertionFailure
Exception reason: ASSERTION FAILURE: 
Reason:     All views needing candidate constraints have already had constraints generated. This most likely indicates a bug involving layout of the following views:
Layout engine frame ({{20, 60}, {282, 57}}) of <UILabel: 0xb36f590; frame = (20 60; 281 57); text = '0'; clipsToBounds = YES; opaque = NO; autoresize = TM+BM; userInteractionEnabled = NO; layer = <CALayer: 0xb36f620>> does not match canvas frame ({{20, 60}, {281, 57}})
Layout engine frame ({{236, 328}, {66, 43}}) of <UIRoundedRectButton: 0xb384590; frame = (236 328; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb384660>> does not match canvas frame ({{236, 328}, {65, 43}})
Layout engine frame ({{236, 124}, {66, 43}}) of <UIRoundedRectButton: 0xb38ea10; frame = (236 124; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb38eae0>> does not match canvas frame ({{236, 124}, {65, 43}})
Layout engine frame ({{236, 175}, {66, 43}}) of <UIRoundedRectButton: 0xb390a30; frame = (236 175; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb36e8e0>> does not match canvas frame ({{236, 175}, {65, 43}})
Layout engine frame ({{236, 226}, {66, 43}}) of <UIRoundedRectButton: 0xb392a90; frame = (236 226; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb392b60>> does not match canvas frame ({{236, 226}, {65, 43}})
Layout engine frame ({{236, 277}, {66, 43}}) of <UIRoundedRectButton: 0xb394b70; frame = (236 277; 65 44); opaque = NO; autoresize = TM+BM; layer = <CALayer: 0xb394c40>> does not match canvas frame ({{236, 277}, {65, 43}})

回答1:

Update: Further experimentation revealed the 'Use Autolayout' checkbox for the storyboard. Switching this off then saving the file seems to have fixed the problem. I can edit at will, with no more crashes.



回答2:

When xib files are in different formats, but are all in the same project, this will happen. In my case, some xib files were compatible for xcode5 dp, but others were for xcode 4.6

The object here is to look for differences in xib files

Hope this helps people in the future!



回答3:

This problem likely has something to do with the now two different sized iPhone retina displays (3.5" and 4") and how that interacts with a view's Mode:Scale To Fill and perhaps Autosize Subviews, also -- both of which are enabled by default.

For example, in my case I had a 4" retina sized MainView with tightly packed button views. But the emulator was set to 3.5 retina display. Because my button views were only 43x43px in size and spaced right next to each other, this would cause the button positions to auto-down-scale in such a way that they overlapped, when their positions were adjusted for the 3.5" display (Scale To Fill a smaller space) -- since they could not shrink in size. This overlapping of views seems likely to cause problems in the auto layout system. Hence the crash, I think.

This will also no doubt be why there is some reference to communicating with the emulator in the crash report, even though we're only working in Interface Builder, which did not previously seem intuitive.



回答4:

I got this error aswell, for me the problem was a TableView that had some constraints left. After deleting all constraints the error stopped showing up.