Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[menu-bar] Focus simulator window when launching an app #75

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Added local HTTP server to circumvent deep-link limitations. ([#52](https://github.com/expo/orbit/pull/52), [#53](https://github.com/expo/orbit/pull/53), [#54](https://github.com/expo/orbit/pull/54), [#55](https://github.com/expo/orbit/pull/55) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Added Projects section to the menu bar. ([#46](https://github.com/expo/orbit/pull/46), [#59](https://github.com/expo/orbit/pull/59) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Added support for login to Expo. ([#41](https://github.com/expo/orbit/pull/41), [#43](https://github.com/expo/orbit/pull/43), [#44](https://github.com/expo/orbit/pull/44), [#45](https://github.com/expo/orbit/pull/45), [#62](https://github.com/expo/orbit/pull/62), [#67](https://github.com/expo/orbit/pull/67) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Focus simulator/emulator window when launching an app. ([#75](https://github.com/expo/orbit/pull/75) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 🐛 Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion apps/menu-bar/macos/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ post_install do |installer|
xcconfig = File.read(xcconfig_path)
xcode_major_version = `(xcodebuild -version | grep -oE '[0-9]*' | head -n 1)`.strip

if $xcode_major_version.to_i >= 15
if xcode_major_version.to_i >= 15
xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
else
xcconfig_mod = xcconfig.gsub(/TOOLCHAIN_DIR/, "DT_TOOLCHAIN_DIR")
Expand Down
2 changes: 1 addition & 1 deletion apps/menu-bar/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,6 @@ SPEC CHECKSUMS:
Swifter: e71dd674404923d7f03ebb03f3f222d1c570bc8e
Yoga: b01d8e70b1bc0e88b40040a7d9c50fdadb1054b9

PODFILE CHECKSUM: 81e540cf8116d2cad65b04b4aed2f9512982ea39
PODFILE CHECKSUM: 3ee64bd16ae5677f1957974b6e7eb9189851163d

COCOAPODS: 1.13.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"scripts": {
"build": "lerna run build",
"watch": "lerna run watch --stream",
"watch": "lerna run watch --stream --parallel",
"typecheck": "lerna run typecheck",
"postinstall": "patch-package"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-shared/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
cache: CACHE_PATH,
log: LOG_PATH,
temp: TEMP_PATH,
} = envPaths("eas-cli");
} = envPaths("expo-orbit");

export const getDataDirectory = (): string => DATA_PATH;
export const getConfigDirectory = (): string => CONFIG_PATH;
Expand Down
6 changes: 5 additions & 1 deletion packages/eas-shared/src/run/android/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export async function installAppAsync(
Log.log("Installing your app...");

assert(emulator.pid);
await activateEmulatorWindowAsync({
pid: emulator.pid,
deviceType: "emulator",
});
await adbAsync("-s", emulator.pid, "install", "-r", "-d", apkFilePath);

Log.succeed("Successfully installed your app!");
Expand Down Expand Up @@ -199,7 +203,7 @@ export async function getAdbOutputAsync(args: string[]): Promise<string> {
}

export async function openURLAsync({ pid, url }: { pid: string; url: string }) {
// await activateEmulatorWindowAsync({ pid });
await activateEmulatorWindowAsync({ pid, deviceType: "emulator" });

try {
// NOTE(brentvatne): temporary workaround! launch Expo Go first, then
Expand Down
1 change: 1 addition & 0 deletions packages/eas-shared/src/run/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function runAppOnAndroidEmulatorAsync(
): Promise<void> {
await assertExecutablesExistAsync();
const bootedEmulator = await Emulator.ensureEmulatorBootedAsync(emulator);
await Emulator.activateEmulatorWindowAsync(bootedEmulator);
await Emulator.installAppAsync(bootedEmulator, appPath);
const { packageName, activityName } = await getAptParametersAsync(appPath);
await Emulator.startAppAsync(bootedEmulator, packageName, activityName);
Expand Down
21 changes: 20 additions & 1 deletion packages/eas-shared/src/run/ios/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export async function launchAppAsync(
): Promise<void> {
Log.newLine();
Log.log("Launching your app...");

await activateSimulatorWindowAsync();
await simctlAsync(["launch", simulatorUdid, bundleIdentifier]);

Log.succeed("Successfully launched your app!");
Expand Down Expand Up @@ -146,6 +146,24 @@ async function waitForSimulatorAppToStartAsync(
throw new Error("Timed out waiting for the iOS simulator to start.");
}

export async function activateSimulatorWindowAsync(): Promise<void> {
await osascript.execAsync(`
tell application "System Events"
set assistiveAccess to UI elements enabled
end tell

if assistiveAccess then
tell application "System Events" to tell process "Simulator"
perform action "AXRaise" of window 0
end tell
else
tell application "Simulator"
activate
end tell
end if
`);
}

async function isSimulatorAppRunningAsync(): Promise<boolean> {
try {
const result = await osascript.execAsync(
Expand Down Expand Up @@ -223,6 +241,7 @@ export async function openURLAsync(options: {
udid: string;
url: string;
}): Promise<void> {
await activateSimulatorWindowAsync();
await xcrunAsync(["simctl", "openurl", options.udid, options.url]);
}

Expand Down