Rob Verger, writing for Popular Science:
Apple built its own algorithms to discern the stroke of swimmers of all skill levels, as well the calories they’re burning. The process involved gathering data from more than 700 swimmers and over 1,500 swim sessions. And Apple gathered even more data from people swimming in place (in an "endless" pool) while wearing a mask that descended from the ceiling.
The watch uses the gyroscope and accelerometer to track the motion of your strokes, but in open water, it can leverage another sensor: the GPS chip. If you’re swimming in the ocean or a lake, your watch uses that to determine how fast and how far you go. But GPS signals don’t travel through H2O. Luckily, people are likely to do freestyle in open water and for that stroke, your arms regularly break the surface. Apple sets the GPS chip in acquisition mode for the whole swim. It looks for the satellite signal each time your hand rises from the water. “We’re trying to catch it every single time,” says Ron Huang, Apple’s director of engineering for location and motion services.
The accelerometer measures motion, and the gyroscope determines how many degrees the watch is rotating per second. Together, those sensors help Apple figure out the stroke type.
Even as someone who dislikes the water—there was a traumatic incident as a child—I found this story fascinating. Apple continues to pull the strong on its health initiatives, of which swimming is a part. Fun read.