AFL premiership winner Dean Cox will replace long-time Sydney Swans coach John Longmire on a four-year deal from 2025.