To me. It's not so much a question of aliens as scapegoats. Here is a population group that for generations had apartheid to scapegoat.
That's not to defend apartheid. But it was undeniably easy to scapegoat.
One day they wake up. It is gone. They have honed one skill; scapegoating. Who do they blame?
I think that is why you don't see the same behavior from Botswanans, who also host large foreign African populations.
The solution would be to obviously find work for these people.
South Africa should have been competing with China for manufacturing jobs from the West.
I think they haven't because their "cheap" labor is too costly; not to mention demanding.
Either way, the leaders are doing next to nothing outside of lip service, to put an end to this problem.