Finding consecutive days in an array of dates
Never use 86,400 seconds as the duration of a day. "Most" days have 24 hours,
but in regions with daylight saving time, a day can have 23 or 25 hours (when the
clock is adjusted one hour forward or back).

Another problem is that you compare the difference in seconds between two days
in order to decide if they are on the same day. Then for example 
"April 3, 10:00" and "April 4, 09:00" will be considered the same day.

There is also a bug in your final loop: The loop is exited if two dates are more
than one day apart, instead of continuing to search for a longer sequence of
consecutive days.

I would start by computing the difference in days to some reference date first:

dates.sort() // Short form for: dates.sort(by: &lt; )
let referenceDate = calendar.startOfDay(for: dates.first!)

let dayDiffs = dates.map { (date) -&gt; Int in
    calendar.dateComponents([.day], from: referenceDate, to: date).day!
}


Now we have an array of (non-decreasing) integers, in your example
that would be

print(dayDiffs)
// [0, 1, 1, 1, 2, 3, 3, 3, 4, 5]


It remains to find the longest
sequence of consecutive numbers (ignoring duplicates) in that array, i.e. no date/calendar calculations
are needed from this point on.

This should be done in a separate function, which could look like this:

/// Find maximal length of a subsequence of consecutive numbers in the array.
/// It is assumed that the array is sorted in non-decreasing order.
/// Consecutive equal elements are ignored.

func maximalConsecutiveNumbers(in array: [Int]) -&gt; Int {
    var longest = 0 // length of longest subsequence of consecutive numbers
    var current = 1 // length of current subsequence of consecutive numbers

    for (prev, next) in zip(array, array.dropFirst()) {
        if next &gt; prev + 1 {
            // Numbers are not consecutive, start a new subsequence.
            current = 1
        } else if next == prev + 1 {
            // Numbers are consecutive, increase current length
            current += 1
        }
        if current &gt; longest {
            longest = current
        }
    }
    return longest
}


The approach is actually similar as in your last loop, only that


we only have to compare integers,
we continue to search for longer subsequences if one consecutive sequence ends,
consecutive equal numbers are simply ignored, so that it is no longer necessary
to remove duplicates in advance,
zip() + dropFirst() is used to iterate over all pairs of adjacent array elements, that saves a look of bookkeeping (dateIndex, 
nextDateIndex).


You should add unit tests to verify that the function works correctly.
This is easier for an array of integers than for an array of dates.

With these preparations, the number of consecutive days is simply obtained as

let consecutiveDaysCount = maximalConsecutiveNumbers(in: dayDiffs)