After fiddling around with this problem for some time, I devised a simple workaround that might (or might not) work for some of you having this problem. What this method does is that it adds the amount of time described in the mentioned radar bug report that causes the bug to appear:
/// Workaround for a known bug in `DateComponentsFormatter` that causes `maximumUnitCount` variable value to be ignored sometimes https://openradar.appspot.com/26354907
///
/// - Parameters:
/// - fromDate: First (earlier) date.
/// - toDate: Second (later) date.
/// - dateFormatter: Instance of `DateComponentsFormatter` with properly set `maximumUnitCount` property.
/// - Returns: Corrected timestamp with only one unit. Eg. `1d 1h` will be corrected to `1d`.
private static func correctedTimestamp(from fromDate: Date, to toDate: Date, dateFormatter: DateComponentsFormatter) -> String? {
guard
let days = Calendar.current.dateComponents([.day], from: fromDate, to: toDate).day,
let hours = Calendar.current.dateComponents([.hour], from: fromDate, to: toDate).hour,
let minutes = Calendar.current.dateComponents([.minute], from: fromDate, to: toDate).minute,
days > 0,
days * 24 - hours == 0,
days * 24 * 60 - minutes < 0,
let timestamp = dateFormatter.string(from: fromDate, to: toDate.addingTimeInterval(Double(days * 24 * 60 - minutes) * 60))
else { return nil }
return timestamp
}