@@ -70,6 +70,10 @@ public final class XcodeInspector: ObservableObject {
7070 public var realtimeActiveWorkspaceURL : URL {
7171 latestActiveXcode? . realtimeWorkspaceURL ?? activeWorkspaceURL
7272 }
73+
74+ public var realtimeActiveProjectURL : URL {
75+ latestActiveXcode? . realtimeProjectURL ?? activeWorkspaceURL
76+ }
7377
7478 init ( ) {
7579 let runningApplications = NSWorkspace . shared. runningApplications
@@ -231,26 +235,35 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
231235
232236 @Published public private( set) var completionPanel : AXUIElement ?
233237
234- public var realtimeDocumentURL : URL {
238+ public var realtimeDocumentURL : URL ? {
235239 guard let window = appElement. focusedWindow,
236240 window. identifier == " Xcode.WorkspaceWindow "
237241 else {
238- return URL ( fileURLWithPath : " / " )
242+ return nil
239243 }
240244
241245 return WorkspaceXcodeWindowInspector . extractDocumentURL ( windowElement: window)
242- ?? URL ( fileURLWithPath: " / " )
243246 }
244247
245- public var realtimeWorkspaceURL : URL {
248+ public var realtimeWorkspaceURL : URL ? {
246249 guard let window = appElement. focusedWindow,
247250 window. identifier == " Xcode.WorkspaceWindow "
248251 else {
249- return URL ( fileURLWithPath : " / " )
252+ return nil
250253 }
251254
252255 return WorkspaceXcodeWindowInspector . extractWorkspaceURL ( windowElement: window)
253- ?? URL ( fileURLWithPath: " / " )
256+ }
257+
258+ public var realtimeProjectURL : URL ? {
259+ guard let window = appElement. focusedWindow else { return URL ( fileURLWithPath: " / " ) }
260+ let workspaceURL = realtimeWorkspaceURL
261+ let documentURL = realtimeDocumentURL
262+ return WorkspaceXcodeWindowInspector . extractProjectURL (
263+ windowElement: window,
264+ workspaceURL: workspaceURL,
265+ documentURL: documentURL
266+ )
254267 }
255268
256269 var _version : String ?
0 commit comments