ChatGPT found a way to deal with this using deprecated symbols:
try NSWorkspace.shared.open([path.url], withAppBundleIdentifier: "com.apple.dt.Xcode", options: .default, additionalEventParamDescriptor: nil, launchIdentifiers: nil)
I suppose there is something wrong with the latest APIs.