How to fix local debugging of Azure Functions in Visual Studio for Mac

UPDATED — 14th January 2021
The bug has now been closed as fixed by Visual Studio — please ensure you have the latest version installed.
UPDATED — installed Big Sur? First ensure that you have updated Visual Studio to version 8.8 release 4 (Wednesday 16th December 2020).
This will resolve an issue where the terminal doesn’t display the Azure function output, instead you would have been greeted with a CLR error.
The rest of this blog covers how I could get Visual Studio working by rolling back the version of Xcode (this worked before I upgraded to BigSur).
Today I tried to run my Visual Studio Azure Function on a Mac, but instead of the terminal showing the Azure function output it displayed nothing.

The root cause appears to be related to this bug https://github.com/dotnet/runtime/pull/42900
Oddly Xcode 12 and .NET 5 don’t play well together. The following issue was raised https://github.com/dotnet/runtime/issues/42311 and this comment from c-lamon solved the terminal issue for me.

I don’t quite understand how Visual Studio for Mac, .NET 5 and Xcode are dependent on each other, but the action of reverting to Xcode 11 does work 🥳
In summary download XCode 11.7 from Apple, rename it (so you can keep Xcode 12.x running too) and move the renamed file to your Applications folder and then tell the operating system which version of XCode should be used.
sudo xcode-select -s /Applications/Xcode_11.app ← To fix Visual Studio on Mac
or
sudo xcode-select -s /Applications/Xcode.app ← Use the latest XCode
Xcode-select controls the location of the developer directory used by xcrun, xcodebuild, cc and other Xcode and BSD development tools.

And voila — Azure functions are now successfully running locally on the Mac through the Visual Studio debugger.

My only disappointment was that the terminal didn’t render the Microsoft Azure Functions ASCII art 😏

Follow me on Twitter - https://twitter.com/codingrob