This seems to be a bug in Xcode 11 (tested in beta 7 and GM Seed 1) - I have filed this issue with Apple via Feedback Assistant (FB7198213). The issue is fixed in Xcode 11 GM Seed 2.
For previous versions of Xcode 11, a workaround for the incorrect behaviour of dynamic label colors is to reassign the label color in awakeFromNib()
in the table view cell subclass. E.g.:
class TableCell: UITableViewCell {
@IBOutlet private weak var label: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
if #available(iOS 13.0, *) {
// The label's textColor was set to secondaryLabel in the XIB editor
// but we reassign it to secondaryLabel again here. This prevents
// a bug where the label always appears in its light mode variant.
label.textColor = .secondaryLabel
}
}
}
Original answer:
This original answer addresses the issue only for the default (i.e. primary) label color
There seems to be a bug in the XIB editor in Xcode 11 (tested in beta 7) with regards to editing label colours. When a label color is set in the XIB editor to "Label Color" (even if it was already set to that), the underlying XML is modified in a way which results in the label appearing black even in dark mode. Examining the diff of a XIB file between the creation of a new label, and after explicitly setting that label's color to "Label Color", one can see the difference.
For my simple example, the XIB file's XML went from:
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text here" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VKH-gX-gtO">
<rect key="frame" x="20" y="15" width="71" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
to:
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text here" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VKH-gX-gtO">
<rect key="frame" x="20" y="15" width="71" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
Note that the line <nil key="textColor"/>
was removed. Manually adding this back fixes the behaviour of the label in dark mode.