Search code examples
macoscocoamacos-sierranstoolbarnstoolbaritem

NSToolbarItem: "Make sure this toolbar item has a valid frame/min/max size"?


Since upgrading to Mac OS Sierra and the new XCode version I get the following error every time I launch my application for every one of the NSToolbarItems:

Example 1:
2016-09-29 12:46:58.659879 AppTest[] NSToolbarItem (<NSToolbarItem: >) had to adjust the size of <NSPopUpButton: > from {130, 26} to the expected size of {132, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
Example 2:
2016-09-29 12:46:58.666074 AppTest[] NSToolbarItem (<NSToolbarItem: >) had to adjust the size of <NSButton: > from {60, 25} to the expected size of {62, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint

I tried messing around in StoryBoard changing the size with no luck, when I searched around I found a couple of people having this issue as well with the new OS but no helpful answers.

Anyone facing the same issue, any advice?

Thanks a lot,

Marc


Solution

  • Was not able to solve this in interface builder. However overriding minSize in subclass of NSToolbarItem solved the issue.

    - (NSSize)minSize
    {
        if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
            /* Overriding this getter seems to be the only solution for runtime error logs like: NSToolbarItem (<APMRegularToolbarItem: 0x60e000039460>) had to adjust the size of <NSButton: 0x60f0001acce0> from {40, 25} to the expected size of {42, 27}. Make sure that this toolbar item view has a valid frame/min/max size. This is an app bug, please do not file a bug against AppKit or NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
             */
            return NSMakeSize(42, 27);
        }
        else {
            return [super minSize];
        }
    }