Foundation.Date conforming to Strideable iOS 13

In trying to compile our code with XC 11 we ran into an ambiguous function error with distance(to:) since we created our own conformance to Strideable on Foundation.Date. It looks like in iOS 13 and above Foundation also added a conformance to Strideable on Date which is causing the ambiguous function issue.

We could remove the conformance, but since we support back to iOS 10.0 we would have to reimplement all the same strideable functions. We tried using the obsoleted macro but that didn't work (since I'm guessing the code is still compiled together). Any thoughts here to support compiling on XC 11?

Unfortunately there's no easy way around this. You could perhaps wrap Date in your own type, but I guess that would be even more work. In general, you shouldn't conform a type you don't own to a protocol you don't own.

8 Likes