Platform Mac is not a valid platform to build. Compile failed

I found the solution on the post below. The issue was related to Xcode 26. So I installed Xcode 16.4 alongside Xcode 26 and selected version 16.4 is the default build tool.