text: You don't choose the new target for the spell until Swerve resolves. You must change the target if possible. However, you can't change the target to an illegal target. If there are no legal targets, the target isn't changed. It doesn't matter if the original target of that spell has somehow become illegal.