30 June 2012 had a leap second. As such it lasted 86401 seconds.
However, in the following Swift code, timeInterval is 86400.
How come?
let formatter = ISO8601DateFormatter()
let date = formatter.date(from: "2012-06-30T00:00:00Z")!
let dayAfter = formatter.date(from: "2012-07-01T00:00:00Z")!
let timeInterval = date.distance(to: dayAfter)
(ps: in what context did I write this code? It was just about having fun with code. I was trying to write confusing code results, but I was disappointed by this attempt at trying to be smart)
The basis for Apple date and time APIs and system implementations is the ICU library, and the underpinnings for most of the results you see depends on ICU behavior. Notably, ICU doesn't support or consider the existence of leap seconds:
As such, Apple platforms also don't represent historical (or future) leap seconds in any way in APIs; systems effectively deal with leap seconds via NTP, and simply set their clocks appropriately, but querying for leap seconds like this won't yield anything.