I wouldn't suggest using swimming to calculate your maximum heart rate, as you have less control over when you breath. Also, you don't want to be out of breath anywhere near water, the potential for passing out and drowning is too great.
Just put on your heart rate monitor, get warmed up, and then sprint as fast as you can until you collapse, most easily done by sprinting uphill. Note your maximum heart rate recorded.
Just hill sprints will get you a better read than 220-age, but the reason, I believe, lab test build up heartrate gradually is that you don't want to test the abilities of your leg muscles to sprint and recover.
Very well trained athletes will notice that they bounce between different body systems limiting their performance as the move through training periods.
Swimming can work as well, but only if you have good technique. I'm not a great swimmer so when I'm panting by the poolside it's because I wasn't breathing correctly, not because I was exceeding my aerobic capacity. Highly trained competitive swimmers don't have this problem.
Just put on your heart rate monitor, get warmed up, and then sprint as fast as you can until you collapse, most easily done by sprinting uphill. Note your maximum heart rate recorded.