Can the bar also be used to attach a swing?

Yes, you can also hang a swing for smaller children on the rail; many customers do that.
The easiest way to do this is simply loop the swing rope around the bar.
The following customer photo explains the principle using a larch wood gymnastics bar as an example

Gymnastic bar with swing

With older children and higher loads, however, it makes more sense to purchase a real, A-shaped swing frame.
Otherwise, due to the strong lateral forces, there is a risk that the foundations could loosen and the system could start to wobble.