Gregor Townsend's side will face the Springboks on July 4 and again on July 11, before travelling to New Zealand toface the All Blacks at Dunedin's Forsyth Barr Stadium (kick-off 8.35am BST).
Start times and venues for both Tests against the World Cup winners are still to be confirmed.
Scotland haven't faced the Boks on South African soil since a crushing 55-6 defeat in Port Elizabeth in June 2014.
The Scots have won five out of 27 meetings with South Africa - all on home soil.
The most recent victory was the 21-17 win in November 2010 as part of the 2010 Grand Slam Tour and, prior to that, a 21-6 success in November 2002 as part of South Africa's tour of Europe.
Before that, there were consecutive wins in the 1860s - 8-5 and 6-3 at Murrayfield in April 1965 and December 1969 - and a 6-0 win in the first meeting between the two nations in November 1906 at Hampden.
Scotland, who host New Zealand at BT Murrayfield in the 2020 Autumn Test series along with Argentina and Japan, have never beaten the All Blacks in 31 attempts - two draws at Murrayfield in 1964 and 1983 the Scots' best results.
Their last matches against the All Blacks on home soil came in the summer of 2000, when the hosts ran out 69-20 winners at Carisbrook in Dunedin and recorded a 48-14 win a week later at Auckland's Eden Park.