Cycling causes my piriformis to get tight...
Best solution for me has been loads of trigger point release - physio can do this, or you can do it yourself literally rolling the muscle over a tennis ball.
And plenty stretching and foam rollering.
Meanwhile, swim to your heart's content - but crawl would probably be better than breast stroke I would have thought.