iOS 27b3 SDK: iOS App on Mac crashes on UISearchBar focus

Our app crashes when compiled with the iOS 27 beta 3 SDK and run as an iOS app on Mac, on both macOS 26 and macOS 27, as soon as a UISearchBar receives focus.

The crash is due to this exception:

*** Assertion failure in BOOL _screenBasedFocusUnsupported(void)(), UIScreen.m:3.725
Accessing the focus system through UIScreen is no longer supported.
(
	0   CoreFoundation                      0x000000018bea31c0 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018b91e91c objc_exception_throw + 88
	2   Foundation                          0x000000018e092644 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] + 0
	3   UIKitCore                           0x00000001c5dae8ec _screenBasedFocusUnsupported + 272
	4   UIKitCore                           0x00000001c5dae960 -[UIScreen _preferredFocusedWindow] + 24
	5   UIKitCore                           0x00000001c4ea3a60 -[UIScreen _mainSceneReferenceBounds] + 200
	6   UIKitCore                           0x00000001c4ea3914 -[UIScreen _mainSceneBoundsForInterfaceOrientation:] + 40
	7   UIKitCore                           0x00000001c5708134 +[UINavigationBar defaultSizeForOrientation:] + 76
	8   UIKitCore                           0x00000001c6222c88 -[_UISearchPresentationController _layoutPresentationWithSize:transitionCoordinator:] + 704
	9   UIKitCore                           0x00000001c622296c -[_UISearchPresentationController containerViewWillLayoutSubviews] + 84
	10  UIKitCore                           0x00000001c549304c block_destroy_helper.13 + 25112
	11  UIKitCore                           0x00000001c549344c block_destroy_helper.13 + 26136
	12  UIKitCore                           0x00000001c4ea26a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1648
	13  QuartzCore                          0x0000000196103dbc _ZN2CA5Layer15perform_update_EPS0_P7CALayerjNS_17LayerUpdateReasonEPNS_11TransactionE + 460
	14  QuartzCore                          0x000000019610390c _ZN2CA5Layer17update_if_needed_EPNS_11TransactionENS_17LayerUpdateReasonE + 692
	15  QuartzCore                          0x0000000196035d2c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 608
	16  QuartzCore                          0x0000000195e69520 _ZN2CA11Transaction6commitEv + 652
	17  AppKit                              0x0000000190fe116c __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.7 + 44
	18  CoreFoundation                      0x000000018be34ad0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
	19  CoreFoundation                      0x000000018be34a10 __CFRunLoopDoBlocks + 396
	20  CoreFoundation                      0x000000018be33e54 __CFRunLoopRun + 2356
	21  CoreFoundation                      0x000000018bf06234 _CFRunLoopRunSpecificWithOptions + 532
	22  HIToolbox                           0x0000000198c1f560 RunCurrentEventLoopInMode + 320
	23  HIToolbox                           0x0000000198c228bc ReceiveNextEventCommon + 488
	24  HIToolbox                           0x0000000198dac14c _BlockUntilNextEventMatchingListInMode + 48
	25  AppKit                              0x00000001909163d0 _DPSBlockUntilNextEventMatchingListInMode + 228
	26  AppKit                              0x000000019026a084 _DPSNextEvent + 576
	27  AppKit                              0x0000000190dff96c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
	28  AppKit                              0x0000000190dff678 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 72
	29  AppKit                              0x000000019025d13c -[NSApplication run] + 368
	30  AppKit                              0x00000001902357b0 NSApplicationMain + 880
	31  AppKit                              0x000000019047c958 +[NSWindow _savedFrameFromString:] + 0
	32  UIKitMacHelper                      0x00000001aa2651bc UINSApplicationMain + 972
	33  UIKitCore                           0x00000001c4e1aed4 UIApplicationMain + 144
	34  UIKitCore                           0x00000001c548bda0 block_destroy_helper.31 + 8880
	35  DigitalConcertHall.debug.dylib      0x0000000106e41bd8 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128
	36  DigitalConcertHall.debug.dylib      0x0000000106e41b4c $s18DigitalConcertHall11AppDelegateC5$mainyyFZ + 32
	37  DigitalConcertHall.debug.dylib      0x0000000106e4afc0 __debug_main_executable_dylib_entry_point + 28
	38  dyld                                0x000000018b9ac4e4 start + 6992
)

I could not test with the iOS 27 beta 4 SDK due to this blocking issue: https://developer.apple.com/forums/thread/839012

However, when I tried to set up a simple sample project, I could not reproduce the issue.

Does anybody know what might be causing this?

I filed feedback FB24201508

Can you confirm if you can reproduce this using iOS Beta 4 and if you can please update the feedback report with a complete symbolicated crash report

I'm a colleague of Tom and updated the feedback with a minimal reproducer.

The crash occurs with a stock UISearchController when the scene-based iOS app has UIApplicationSupportsMultipleScenes = false. Changing it to true prevents the crash, but changes the app’s intended scene behavior. The assertion originates entirely inside UIKit through _UISearchPresentationController and UIScreen._preferredFocusedWindow.

This is still unresolved in the final iOS SDK and unfortunately also no updates in our feedback.

The issue has been fixed on macOS 27.2 beta.

Since older macOS versions are still affected when the app is build with the iOS 27 SDK, we will have to limit the availability of our iOS on Mac to 27.2 and newer.

iOS 27b3 SDK: iOS App on Mac crashes on UISearchBar focus
 
 
Q