kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.39k stars 128 forks source link

Cannot get Simulator windows immediately after Phoenix loads #259

Closed Drarok closed 2 years ago

Drarok commented 4 years ago

If I attempt to access the iOS Simulator's windows immediately on load of Phoenix, no windows are returned. If I do so on appDidActivate, the windows are available as expected.

function dump(prefix, app) {
  const windows = app.windows().map((win, idx, all) => `${idx}: ${win.title()}`);
  Phoenix.log(`DEBUG ${prefix} ${app.name()}: ${JSON.stringify(windows)}`);
}

dump('LAUNCH', App.get('Simulator'));
dump('LAUNCH', App.get('Console'));

setTimeout(() => {
  dump('DELAYED LAUNCH', App.get('Simulator'));
  dump('DELAYED LAUNCH', App.get('Console'));
}, 2000);

Event.on('appDidActivate', (app, win) => {
  dump('ACTIVATE', app);
});

Output:

Phoenix DEBUG LAUNCH Simulator: []
Phoenix DEBUG LAUNCH Console: ["0: Console (8 messages)"]
Phoenix DEBUG DELAYED LAUNCH Simulator: []
Phoenix DEBUG DELAYED LAUNCH Console: ["0: Console (11 messages)"]
Phoenix DEBUG ACTIVATE Simulator: ["0: iPhone 11 (13.4)","1: iPhone 5 (SE) (13.4)","2: iPhone 8 (13.4)","3: iPhone 11 Pro (13.4)"]
kasper commented 4 years ago

@Drarok Hey! Is this on system startup or how does the iOS Simulator launch? App.get is not a blocking function, so it returns the current state of the system at any given time.