Can a foreigner become the president of South Africa?
Short answer: yes. If "foreigner" includes a foreign-born person who has become naturalized.
According to the South African Constitution, any citizen who is entitled to vote with some exceptions that do not include foreign birth can become a member of parliament (Section 47). Parliament (National Assembly) elects the president from among their members (Section 86) and, once elected, the president ceases to be an MP (Section 87).
So there is nothing to preclude a foreigner from being elected, provided they have citizenship, are entitled to vote and are not disqualified for any of the reasons that apply to non-foreigners. And they need to be elected to parliament, which is usually easy if your party has enough votes to make you a presidential candidate since the voting system is pure proportional representation.
Dual citizenship is also not a disqualifier, as it is in Australia (only at federal level; dual citizens can be elected to local and state office). You may think this is a problem for South Africa but recently in Australia, a number of MPs and senators have fallen afoul of this for reasons like immigrating when they were very young and not realizing that their parents had failed to renounce their original citizenship.
By comparison with other countries, a "birther" bogus issue as in the US could not arise, nor could the fiasco in Australia where elected politicians more or less by accident find themselves disqualified.
Aside from practicalities, there is a principle: if you are qualified to vote you should be qualified for any office unless there is a strong reason to disqualify you. South Africa has it right; the US and Australia do not. Their constitutions promote xenophobia.