Crash sectionHeaderTopPadding on iOS 14

Firebase logged crash

Crashing on exception: -[UITableView setSectionHeaderTopPadding:]: unrecognized selector sent to instance 0x1589ca800

After checking code everywhere is call

if #available(iOS 15.0, *) {
    tableView.sectionHeaderTopPadding = 0.0
}

Stack trace:

Crashed: com.apple.main-thread
0  AppKit                         0x3dda28 -[NSApplication _crashOnException:] + 372
1  AppKit                         0x3dd70c -[NSApplication reportException:] + 588
2  AppKit                         0x31f10 -[NSApplication run] + 792
3  AppKit                         0x3878 NSApplicationMain + 1064
4  AppKit                         0x2f2ad0 _NSApplicationMainWithInfoDictionary + 22
5  UIKitMacHelper                 0x4e18 UINSApplicationMain + 1280
6  UIKitCore                      0x2b1c UIApplicationMain + 164
7  TARGET                 0x11358 main + 20 (AppDelegate.swift:20)
8  libdyld.dylib                  0x18430 start + 4

Find out, that crash occures when using macbook with m1 processor.

Answered by ForumsContributor in 692227022

I was seeing the same crash on M1 Macs. Apparently it's a bug with the availability check in Swift. It's a known issue that's listed in the Xcode 13 release notes .

The suggested workaround is to add a check for operatingSystemVersion.majorVersion following the availability check.

For example:

if #available(iOS 15, *), ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 15 {
     tableView.sectionHeaderTopPadding = 0.0
}



Here's the forum post where I found the solution https://developer.apple.com/forums/thread/691559

Hi, I have the same crash. Did you find some solution or workaround for this issue?

I have the same crash.

Can you post an Apple crash report for this issue? See Posting a Crash Report for advice on how to do that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

I was seeing the same crash on M1 Macs. Apparently it's a bug with the availability check in Swift. It's a known issue that's listed in the Xcode 13 release notes .

The suggested workaround is to add a check for operatingSystemVersion.majorVersion following the availability check.

For example:

if #available(iOS 15, *), ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 15 {
     tableView.sectionHeaderTopPadding = 0.0
}



Here's the forum post where I found the solution https://developer.apple.com/forums/thread/691559

Crash sectionHeaderTopPadding on iOS 14
 
 
Q