An 89th-minute winner from Andy Mitchell boosted Dungannon's hopes of avoiding a relegation play-off as Coleraine ended the game with 10 men.
McCafferty hit the bar with a 20-yard volley in the first half and the Swifts also had a number of chances to score.
Mitchell fired in a rebound for the winner after Jamie Glackin's assist.
Bannsiders midfielder McCafferty received a straight red card in the final minute for a foul on Glackin and Coleraine now drop to eighth position.
The Swifts had first-half chances but Abi Sanusi and Gary Liggett fired just wide of the post.
After the break, Darren McCauley shot over, Ruaidhri Higgins twice went close and McCafferty's long-range effort was easily gathered by Andy Coleman.
For the Swifts, Mitchell was off-target and Terry Fitzpatrick had the ball in the net but Matt Hazley's cross was deemed to have crossed the goal-line and the 'goal' was ruled out.
Gary Liggett almost broke the deadlock but his strike came back off the post.