South Africa has pledged decisive action against perpetrators of xenophobic violence targeting foreign nationals, after Ghana formally protested over incidents involving its citizens.