I find the earlierDate method.
if date1.earlierDate(date2).isEqualToDate(date1) {
print("date1 is earlier than date2")
}
You also have the laterDate method.
Swift 3 to swift 5:
if date1 < date2 {
print("date1 is earlier than date2")
}