Yes, though swimming will give you more of a workout overall. Anything cardio is good in regards to swimming when it comes to endurance, it's about regulating your breath.
Cycling is great cardio and will work out your lungs and legs fantastically. Unfortunately it'll do nothing for your upper body, which is also important for swimming. You'll need to come up with a routine that adds in upper body strength and endurance.