The game, which will be preceded by an open training session involving both teams at Tynecastle, will take place on July 18.
"Manchester City are honoured to join with Hearts as they celebrate the centenary of their main stand at the Tynecastle Stadium," said chief executive Ferran Soriano.
A Hearts spokesperson added: "The Main Stand, which is an iconic landmark in British football, celebrates its centenary this year and what better way to mark the milestone than with a glamour friendly against one of the world's top club sides?
"While recognising the past, the match will also see Hearts welcome the future and the game will be the first one at Tynecastle under new ownership and it will be head coach Robbie Neilson's first home game in charge."
City will subsequently fly to the United States for friendlies against Sporting Kansas City, AC Milan, Liverpool and Olympiacos before returning for the Community Shield against FA Cup winners Arsenal on August 10.