The exhibition between the tennis legends will take place at Cape Town Stadium on Feb. 7, staged under the banner of the Roger Federer Foundation, which is involved in charitable work in Africa.
It will be preceded by a doubles match in which Federer will partner Microsoft founder Bill Gates and Nadal will play alongside South African comedian Trevor Noah.
Federer described the match in Africa as "a dream come true" when announcing the exhibition last week, and he said subsequently at Wimbledon, after defeating Lucas Pouille in the third round on Saturday, that "it took me two years to find a date."
"I was trying to be as little as possible annoying to the guy as I could have been," Federer said when asked about the difficulties involved in fitting the exhibition into his and Nadal's schedules.
"But still I had to force the issue at some stage.
"It was like, Rafa, please... "
Federer, who's mother, Lynette, is South African, hailing from Kempton Park in Gauteng, said he had "always wanted to play in South Africa."
"I've hardly played tennis [in South Africa] because I've barely been on vacation to South Africa. So for me to play there now, it's a proper thrill.
"Yeah, I mean, it's not easy. But you know how it is in life: when something is a priority, you find time. I'm happy to go there.
"Obviously will take the family. Looking forward to do also a trip to one of the projects while I'm down there. Love to do a safari, as well. You name it. We'll just have to see what I can fit in, depending on the Australian Open, as well."
Federer, who is chasing his record-extending ninth men's singles title at Wimbledon, has said previously that family trips to South Africa had inspired him to start his foundation when he was just 22.
He said in 2017 that his motivation to establish his foundation came "from the values of my parents; and me, myself, when I was young being in South Africa... seeing that Switzerland is different to southern Africa, that you can have a big impact if you do it the right way".
Federer said at Wimbledon that he hoped his federation, beyond its humanitarian work, could also "have an impact, as well... through inspiring a new generation of tennis players there."
"I hope I have had a little bit of an impact, as well, because of my mom."