The only tweak required for me was to select ST-Link in the debug section of the project config inside CoIDE.

Remember with ST-Link you need to connect the voltage sense to the 3.3v.
You will also get such an error if the model is in the low power halt/sleep mode, as SWD shuts down then (RtcEnterLowPowreStopMode() achieves this unfortunately so take care).