"I like swimming."
Translation:Ich schwimme gern.
I always got taught in my German lessons that 'gern' tends to be used when you are 'liking' a verb.
For example, when we use a conjugation of mögen - Ich mag das Bett = I like the bed The object 'being liked' in this situation is the bed, which is a noun, so we would use the verb 'mögen' or another accepable alternative dependong on what you want to say (e.g. lieben, hassen)
In the case of 'gern', we could say - Ich renne gern = I like running The thing being liked in this instance is the running, which is a verb. You would therefore use this 'gern' after the verb to imply that it is something you enjoy. Generally the rule of thumv is to ask 'what is the object/verb in question' when presented with a sentance.
I'm not a native speaker, so please correct me if I'm wrong but I hope this helps!
You used the wrong word. Ich mag es zu schwimmen.
Is that a valid translation? I like it to swim?