From 7218d2542b9f4249a6c1e34366960a75832e9256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 23 Dec 2024 21:15:37 +0100 Subject: [PATCH] refactor: infer platform sdk from platform name for installApp --- .../src/lib/commands/run/installApp.ts | 17 ++++++++++++++--- .../src/lib/commands/run/runOnSimulator.ts | 4 +--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/plugin-platform-apple/src/lib/commands/run/installApp.ts b/packages/plugin-platform-apple/src/lib/commands/run/installApp.ts index d31525288..d9d30f225 100644 --- a/packages/plugin-platform-apple/src/lib/commands/run/installApp.ts +++ b/packages/plugin-platform-apple/src/lib/commands/run/installApp.ts @@ -6,7 +6,6 @@ import { ApplePlatform, XcodeProjectInfo } from '../../types/index.js'; import spawn, { SubprocessError } from 'nano-spawn'; type Options = { - buildOutput: string; xcodeProject: XcodeProjectInfo; sourceDir: string; mode: string; @@ -18,7 +17,6 @@ type Options = { }; export default async function installApp({ - buildOutput, xcodeProject, sourceDir, mode, @@ -34,7 +32,7 @@ export default async function installApp({ xcodeProject, sourceDir, mode, - buildOutput, + `export PLATFORM_NAME=${getPlatformSDK(platform)}`, // simulate build output scheme, target ); @@ -86,3 +84,16 @@ export default async function installApp({ throw error; } } + +function getPlatformSDK(platform: ApplePlatform) { + switch (platform) { + case 'ios': + return 'iphonesimulator'; + case 'macos': + return 'macosx'; + case 'tvos': + return 'appletvsimulator'; + case 'visionos': + return 'xrsimulator'; + } +} diff --git a/packages/plugin-platform-apple/src/lib/commands/run/runOnSimulator.ts b/packages/plugin-platform-apple/src/lib/commands/run/runOnSimulator.ts index 838f44732..b83adc9be 100644 --- a/packages/plugin-platform-apple/src/lib/commands/run/runOnSimulator.ts +++ b/packages/plugin-platform-apple/src/lib/commands/run/runOnSimulator.ts @@ -43,9 +43,8 @@ export async function runOnSimulator( } loader.stop(`Launched Simulator "${simulator.name}".`); - let buildOutput; if (!binaryPath) { - buildOutput = await buildProject( + await buildProject( xcodeProject, sourceDir, platform, @@ -58,7 +57,6 @@ export async function runOnSimulator( loader.start(`Installing the app on "${simulator.name}"`); await installApp({ - buildOutput: buildOutput ?? '', xcodeProject, sourceDir, mode,