Here's what works for me in Xcode 14:
tell application "Xcode"
set x to path of last item of source documents
display dialog x
end tell
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: