I am also running Sonoma (though I configured it using Ventura). It might still work. Just download Xcode 14.3.1 (https://download.developer.apple.com/Developer_Tools/Xcode_14.3.1/Xcode_14.3.1.xip)
Unzip it, rename Xcode.app to Xcode_14.3.1.app and move it to /Applications.
Execute sudo xcode-select -s /Applications/Xcode_14.3.1.app/Contents/Developer.
Not 100% sure, this will work, but it could.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: