Assertion failure when setting keyboardAppearance on UITextView using UIAppearance

Number:rdar://33846788 Date Originated:11-Aug-2017 01:20 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 9/10/11
Classification:Crash/Hang/Data Loss Reproducible:Always
2017-08-11 13:03:35.872676+0200 TextViewKeyboardAppearance[8866:2782839] *** Assertion failure in void PushNextClassForSettingIMP(id, SEL)(), /BuildRoot/Library/Caches/
2017-08-11 13:03:50.953630+0200 TextViewKeyboardAppearance[8866:2782839] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Please file a radar on UIKit with this log if you see this assertion. selectorString = setKeyboardAppearance:, exercisedImplementations = {
    "setKeyboardAppearance:" =     (

Setting the keyboardAppearance on UITextView using UIAppearance using the following code triggers the above assertion:

let textView = UITextView.appearance()
textView.keyboardAppearance = .dark

Setting any other property (e.g. tintColor) works fine. Setting keyboardAppearance on UITextField via UIAppearance works fine as well. The assertion only happens with UITextView. Setting keyboardAppearance directly, without using UIAppearance, on UITextView works fine as well.

This apparently also only happens if there is a text view in the view hierarchy. When not adding the text view in ViewController.swift in the attached sample project, the assertion is not triggered.

Tested on Xcode 8.3.3 + 9b5 / iOS 9, 10, 11b5 on Simulator and device.

Steps to Reproduce:
- Open the attached sample project in Xcode 8 or 9.
- Run it on any device or Simulator

Expected Results:
No assertion is triggered.

Actual Results:
Assertion in UIAppearance.m is triggered.

iOS 9/10/11

See AppDelegate.swift/ViewController.swift for the UIAppearance/UITextView setup.


Sample project:

By stefan.kieleithner at Aug. 11, 2017, 11:24 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!