File tree Expand file tree Collapse file tree
Core/Sources/XcodeInspector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,7 +211,15 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
211211 super. init ( runningApplication: runningApplication)
212212
213213 observeFocusedWindow ( )
214- observe ( )
214+ observeAXNotifications ( )
215+
216+ if !( focusedWindow is WorkspaceXcodeWindowInspector ) {
217+ // Sometimes the focused window may note be ready on app launch.
218+ Task {
219+ try await Task . sleep ( nanoseconds: 2_000_000_000 )
220+ observeFocusedWindow ( )
221+ }
222+ }
215223 }
216224
217225 func observeFocusedWindow( ) {
@@ -248,11 +256,14 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
248256 }
249257
250258 func refresh( ) {
251- ( focusedWindow as? WorkspaceXcodeWindowInspector ) ? . refresh ( )
252- observe ( )
259+ if let focusedWindow = focusedWindow as? WorkspaceXcodeWindowInspector {
260+ focusedWindow. refresh ( )
261+ } else {
262+ observeFocusedWindow ( )
263+ }
253264 }
254265
255- func observe ( ) {
266+ func observeAXNotifications ( ) {
256267 longRunningTasks. forEach { $0. cancel ( ) }
257268 longRunningTasks = [ ]
258269
You can’t perform that action at this time.
0 commit comments