The South African situation is most unfortunate. Me and my daughter lived through 5 episodes of these attacks, the last we witnessed being in 2015. It is a deep and complicated issue and it is more than what we merely see and hear on the surface. In the first place, the entire Southern Africa has been very isolated from the rest of the world, and they are only recently coming in contact with outsiders, especially other Africans from other regions, and who are very distinctly different and can navigate with more ease than the locals. This is particularly so in South Africa, where the levels of poverty and education are gross. Then there is also the question of inequality, especially the new inequality of the new Black elite, who have left their fellow poor Blacks far far behind. The underprivileged Blacks regularly explode in violence in the townships over inadequate or lack of government services, usually dismissed in the official propaganda as the work of a third force, and the official response always is to send in the police to beat up and shoot at protestors. Very truly a classic African pattern of things.
So the frustrated locals find it easy to vent their anger on helpless foreigners, who in most cases, are also struggling like them, especially poor Zimbabweans, and Mozambicans, and Angolans. There's also plenty of instigation behind this violence, and the corrupt government, also anti immigrant, especially anti African immigrant, capitalizes on this. It's why you hear the government ministers making crazy and stupid statements about immigrants during these incidents. About Nigerian involvement in crime in SA - there is some of this, but it's done in collusion with local South Africans, including the police. And in most cases. some of the guys who do crime are fellows who run into trouble with their visas; it is, in short, a heavily sociological problem of urban pressures on the poor and uprooted in every city on the African continent, and which our governments can not and do not want to address, except in the manner of applying brute force, which doesn't solve any problem.