I thought "swinging the compass" was to compensate for all the magnetic things on the boat.
*Swinging the compass is what you do to compensate for everything, including the way the compass was set when it left the factory.* So it compensates for any magnetic influences in the boat's structure, influences that might occur from electrical systems that are on when the boat is being navigated, variations in the earth's magnetic field where you are boating, etc.
Depending on where one lives, GPS is not always the best guide to use for swinging the compass.* The best way to do it in our experience--- albeit not necessarily the easiest way--- is to select easily-spotted, charted*objects that don't move around like buildings and other structures on shore and plot lines between them on the chart.* Ideally you want at least a triangular set of lines although they don't need to form an actual triangle.* Then you plot and jot down the magnetic bearing of each line in each direction.
Then you take the boat out, line it up between the two points that create one of the lines and hold the boat on that line while adjusting the compass to read the plotted magnetic direction of the line.* Then you turn the boat around and set the compass (if it needs setting) to match the bearing in the other direction.* Then you do the same for your other lines.
If you're lucky, you'll get the compass to read accurately in all directions on all the lines.* But the reality is that you'll get it close but not right on in very direction.* So then you make up a compass deviation chart that says if the compass reads this, you're boat is really doing this.