I have an app that loads a xib with a segmented control. If I build it with Xcode 15 beta 3 and launch on a iPad with iPadOS 17 (or on iOS 17 simulator), it crashes with an error:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UIRecessedMaterialView because no class named _UIRecessedMaterialView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)' First throw call stack: ( 0 CoreFoundation 0x00007ff80048c88a __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff800057894 objc_exception_throw + 48 2 CoreFoundation 0x00007ff80048c768 -[NSException initWithCoder:] + 0 3 UIFoundation 0x00007ff804a1eb4d UINibDecoderDecodeObjectForValue + 352 4 UIFoundation 0x00007ff804a1eebe UINibDecoderDecodeObjectForValue + 1233 5 UIFoundation 0x00007ff804a1e9e2 -[UINibDecoder decodeObjectForKey:] + 257 6 UIKitCore 0x0000000108c04a9f -[UIView initWithCoder:] + 1327 7 UIKitCore 0x0000000107c32c81 -[UIControl initWithCoder:] + 65 8 UIKitCore 0x0000000107c5a7b3 -[UISegmentedControl initWithCoder:] + 65 9 UIFoundation 0x00007ff804a1ecb4 UINibDecoderDecodeObjectForValue + 711 10 UIFoundation 0x00007ff804a1e9e2 -[UINibDecoder decodeObjectForKey:] + 257 11 UIKitCore 0x000000010801c7cd -[UIRuntimeConnection initWithCoder:] + 125 12 UIKitCore 0x000000010801cbef -[UIRuntimeEventConnection initWithCoder:] + 59 13 UIFoundation 0x00007ff804a1ecb4 UINibDecoderDecodeObjectForValue + 711 14 UIFoundation 0x00007ff804a1eebe UINibDecoderDecodeObjectForValue + 1233 15 UIFoundation 0x00007ff804a1e9e2 -[UINibDecoder decodeObjectForKey:] + 257 16 UIKitCore 0x0000000108015a79 -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 447 17 UIKitCore 0x000000010801877e -[UINib instantiateWithOwner:options:] + 1118 18 UIKitCore 0x000000010801a112 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 139 19 CustomSearchBarBug 0x000000010671830e $s18CustomSearchBarBug11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0m6LaunchL3KeyaypGSgtF + 462 20 CustomSearchBarBug 0x0000000106718687 $s18CustomSearchBarBug11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0m6LaunchL3KeyaypGSgtFTo + 183 21 UIKitCore 0x000000010857a092 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 297 22 UIKitCore 0x000000010857be6b -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4253 23 UIKitCore 0x000000010858196b -[UIApplication _runWithMainScene:transitionContext:completion:] + 1241 24 UIKitCore 0x00000001078e6780 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 181 25 UIKitCore 0x000000010857e1dc -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59 26 UIKitCore 0x000000010857e591 -[UIApplication _run] + 936 27 UIKitCore 0x000000010858301a UIApplicationMain + 123 28 UIKitCore 0x000000010764e103 __swift_destroy_boxed_opaque_existential_1Tm + 10851 29 CustomSearchBarBug 0x0000000106718b1b $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 123 30 CustomSearchBarBug 0x0000000106718a97 $s18CustomSearchBarBug11AppDelegateC5$mainyyFZ + 39 31 CustomSearchBarBug 0x0000000106718b88 main + 24 32 dyld 0x00000001068a23ee start_sim + 10 33 ??? 0x000000010dfd041f 0x0 + 4529652767 ) libc++abi: terminating due to uncaught exception of type NSException
The simplest xib to reproduce the crash is:
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="22138.1" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="ipad7_9" orientation="portrait" layout="fullscreen" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clipsSubviews="YES" contentMode="scaleToFill" id="63">
<rect key="frame" x="0.0" y="0.0" width="744" height="1133"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="bar" selectedSegmentIndex="0" id="10">
<rect key="frame" x="218.5" y="5.5" width="331" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="Item"/>
<segment title="Brand"/>
</segments>
<connections>
<action selector="segmentedControlChanged:" destination="-1" eventType="valueChanged" id="25"/>
</connections>
</segmentedControl>
</subviews>
<nil key="simulatedStatusBarMetrics"/>
<point key="canvasLocation" x="467.96875" y="146.484375"/>
</view>
</objects>
</document>
The xib is loaded like this:
let nibs = Bundle.main.loadNibNamed("SegmentedControl", owner: nil, options: nil)
No crash occurs on iOS 16.3.1.
Is there any fix?
The crash is resolved in Xcode 15 beta 6