South Africa has pushed back against accusations of xenophobia, following a wave of anti-migrant protests that has unsettled communities across the country and drawn criticism from elsewhere on the African continent.