Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
429
31
I have a baffling error in Interface builder in XCode 13.3. When I analyze my project I get two errors for two NSTextFields in an .xib:

file:///Users/myName/*Projects/ProjectName%20X/Base.lproj/xibName.xib: notice: Incorrect Intrinsic Size: NSTextField's height does not match its intrinsic content size, use "Size to Fit Content" to correct

Huh? If there's a "Size to Fit Content" option in the object inspector panes for an NSTextField or its child type NSTextFieldCell I can't find it. This error also seems to be disabling my ability to connect an IBOutlet *objectType objectName to an object in the .xib. Is this a new horrible bug in XCode?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
429
31
I worked on this for a long time this morning. I found the "Size to Fit Content" menu item. No matter what you click on, either the NSTextField or its child NSTextFieldCell, the "Size to Fit Content" menu item is never active, so it can't be used to fix this error. You can get rid of this error for a single line NSTextField by setting the height to the default for the text size but you can't remove this error for a text field that has a greater than one line text field where the text will wrap. This is one of several horrible new bugs in XCode Interface builder that make it difficult to develop interfaces in a .xib.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
429
31
It turns out that you can suppress these errors by adding constraints. In newer versions of XCode / Interface Builder you are more or less required to use constraints and auto resizing. These are an example of severe over-kill for most UI designs. They add a lot of complexity for almost no benefit.
 

appgineers

macrumors newbie
Nov 10, 2014
3
0
I had the same issue today. "Size to Fit Content" was greyed out for me, first. Restarting Xcode made it come back. (Xcode version: 13.4.1)
Even simpler: "Size to Fit Content" is also re-enabled if you tap one of the corner handles of the label.
 
Last edited:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
429
31
XCode is doing this to me again. I tried to set the NSTextField's height to different heights but there isn't any height that won't result in this error. Thanks for the tip on clicking on the frame to activate the Size to Fit Content menu item. After I tell Interface Builder to fix this error it isn't fixed - The size of the NSTextField doesn't change and XCode still reports this as a error. Adding constraints from the Editor->Resolve Auto Layout Issues->Reset to Suggester Constraints doesn't add all of the needed constraints so I get a different error - missing constraint... Also it will change the size of some NSText Fields to some random, ridiculously small size. This is just another horrible bug in XCode/Interface Builder that Apple will probably never fix. I searched the Developer Documentation for a guide about how to use these unnecessary, overkill buggy "features" but I can't find one. If anyone can provide a like to a guide on how to use this I would appreciate it.

I tried to report this as a bug but Feedback Assistant is off-line this morning. Update: Feedback Assistant back online- bug reported.
 
Last edited:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
429
31
Looking at the documentation it appears that Apple has (unofficially) deprecated Interface Builder, Objective C and documentation in Objective C. The documentation describes developing GUIs in Swift with Swift UI only. This is a huge bummer for someone like me that is responsible for huge projects written in Objective C with complex GUIs implemented with .xibs. Also Mac development is the red-headed step child of Apple development, de-emphasized in favor of iOS. I will probably stop developing software for the Mac after I release the next version of one of the Apps (if I can even do it with the horrible bugs in XCode like exit(173)).
 

prime17569

macrumors regular
May 26, 2021
207
524
Looking at the documentation it appears that Apple has (unofficially) deprecated Interface Builder, Objective C and documentation in Objective C. The documentation describes developing GUIs in Swift with Swift UI only. This is a huge bummer for someone like me that is responsible for huge projects written in Objective C with complex GUIs implemented with .xibs. Also Mac development is the red-headed step child of Apple development, de-emphasized in favor of iOS. I will probably stop developing software for the Mac after I release the next version of one of the Apps (if I can even do it with the horrible bugs in XCode like exit(173)).

Indeed, Apple sees Swift and SwiftUI as the future of development on their platforms, as they said in the Platforms State of the Union at WWDC 2022.

That doesn't mean that Interface Builder and Objective-C are deprecated (yet), though new iOS frameworks (e.g. WeatherKit) are Swift-only and many of Apple's apps are only using SwiftUI for new features. In fact, until a few months ago one of my apps included an Objective-C swizzle to work around a bug in SwiftUI's UIKit layer - so Objective-C is still going to be needed for a while.

I do agree with you that Apple does seem to be pushing developers away from AppKit Mac app development and toward either multi-platform apps with SwiftUI or iPad apps that support macOS through Catalyst, especially with the introduction of "desktop-class" APIs in iPadOS 16 (e.g. expansions to UIToolbar that give it even more functionality of NSToolbar and that allow it to automatically convert to a real NSToolbar in Mac Catalyst apps, and the addition of an
equivalent to macOS's document proxy title/icon).
 

ChrisWalken

macrumors newbie
Jul 17, 2023
1
0
A work around for this mess is to right click on the xib and open it as "Source Code". Just add a space at the end of any line then close the edit. Kind of a hack, but you gotta do what you gotta do because of what they done to you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.