Xcode 12 creates defective nib files from storyboards for macOS 10.11 and 10.12

Originator:tempelmann
Number:rdar://FB8989554 Date Originated:04 Feb 2021
Status:Open Resolved:
Product:Xcode Product Version:12.4
Classification:Incorrect/Unexpected Behavior Reproducible:Always
 
Issue:

macOS apps made with Xcode 12 do not correctly create standard NSButtons for deployment on 10.11 and 10.12 (I have not tested 10.10):

The problem is that when I use a standard "OK" button, with the Return key as its accelerator key, the button should appear highlighted as the default button, e.g. usually in blue. But on 10.11 and 10.12, the button does not appear in blue but just like any other button (white).

Steps to reproduce:

1. Open Xcode 12.x on Big Sur
2. Create a new project, choosing macOS App, with storyboard, appkit, ObjC.
3. In the storyboard's single View Controller Scene, add an NSButton, and set its caption to "OK". This should automatically designate it as the default button and make it blue.
4. Build the app. Run it. See that the OK button is blue as it should be.
5. Change the project settings set that the deployment target is macOS 10.11
6. Build again, run, and verify the button is still blue.
7. Copy the built app to a Mac running 10.11 or 10.12.
8. Run the app on the older macOS. The button is not blue but white.

Now, if open the same project in Xcode 9 or 10, and build app, you'll see that the OK button will appear in blue on macOS 10.11 and 10.12. This suggest that this is a bug introduced in Xcode 12 (or perhaps already in Xcode 11, I didn't check).

I also had a look at the generated nib files and could identify what went wrong:

The view's nib file (e.g. XfG-lQ-9wD-view-m2S-Jp-Qdl.nib in the attached project) contains a field named NSButtonFlags for each button. When built with Xcode 12, it has the value -2038415360 (0x86804000). Built with Xcode 10, it has the value -2038284288 (0x86824000). So the difference is bit 18 - it needs to be set, but Xcode 12 does not set it. I could not find anything online explaining the meaning of this bit, but I'm sure you'll know.

For now, I'll simply hand-fix the bit in my nib files when releasing my app, but I hope that the next Xcode version will get this right. Or at least offer a way to have control over this.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!