From 91e1f35028993d15dcc00841fc6ed63982e9198e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 1 Oct 2025 14:22:32 +0200 Subject: [PATCH 1/4] fix: run:ios with non-app targets ordered first --- .../src/lib/commands/run/getBuildSettings.ts | 51 +++++++++---------- .../src/lib/utils/pods.ts | 11 ++-- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts b/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts index 76fe1e3cb..218e77c72 100644 --- a/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts +++ b/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts @@ -39,7 +39,7 @@ export async function getBuildSettings({ ? getSimulatorPlatformSDK(platformName) : getDevicePlatformSDK(platformName); - const { stdout: buildSettings } = await spawn( + const { stdout: buildSettingsOutput } = await spawn( 'xcodebuild', [ xcodeProject.isWorkspace ? '-workspace' : '-project', @@ -64,13 +64,22 @@ export async function getBuildSettings({ action: string; buildSettings: BuildSettings; target: string; - }[] = JSON.parse(buildSettings).filter( - ({ target }: { target: string }) => - target !== 'React' && target !== 'React-Core', + }[] = JSON.parse(buildSettingsOutput).filter( + ({ + buildSettings: { WRAPPER_EXTENSION }, + }: { + buildSettings: BuildSettings; + }) => WRAPPER_EXTENSION === 'app' || WRAPPER_EXTENSION === 'framework', ); const targets = settings.map( ({ target: settingsTarget }: { target: string }) => settingsTarget, ); + if (settings.length === 0) { + throw new RockError( + `Failed to get build settings for your project. Looking for "app" or "framework" wrapper extension but found: ${wrapperExtension}`, + ); + } + let selectedTarget = targets[0]; if (target) { @@ -89,31 +98,21 @@ export async function getBuildSettings({ // Find app in all building settings - look for WRAPPER_EXTENSION: 'app', const targetIndex = targets.indexOf(selectedTarget); - const targetSettings = settings[targetIndex].buildSettings; - - const wrapperExtension = targetSettings.WRAPPER_EXTENSION; - - if (wrapperExtension === 'app' || wrapperExtension === 'framework') { - const buildSettings = settings[targetIndex].buildSettings; - - if (!buildSettings) { - throw new RockError('Failed to get build settings for your project'); - } - - const appPath = getBuildPath(buildSettings, platformName); - const infoPlistPath = buildSettings.INFOPLIST_PATH; - const targetBuildDir = buildSettings.TARGET_BUILD_DIR; + const buildSettings = settings[targetIndex].buildSettings; - return { - appPath, - infoPlistPath: path.join(targetBuildDir, infoPlistPath), - bundleIdentifier: buildSettings.PRODUCT_BUNDLE_IDENTIFIER, - }; + if (!buildSettings) { + throw new RockError('Failed to get build settings for your project'); } - throw new RockError( - `Failed to get build settings for your project. Looking for "app" or "framework" wrapper extension but found: ${wrapperExtension}`, - ); + const appPath = getBuildPath(buildSettings, platformName); + const infoPlistPath = buildSettings.INFOPLIST_PATH; + const targetBuildDir = buildSettings.TARGET_BUILD_DIR; + + return { + appPath, + infoPlistPath: path.join(targetBuildDir, infoPlistPath), + bundleIdentifier: buildSettings.PRODUCT_BUNDLE_IDENTIFIER, + }; } function getBuildPath( diff --git a/packages/platform-apple-helpers/src/lib/utils/pods.ts b/packages/platform-apple-helpers/src/lib/utils/pods.ts index 72697fa06..254056f37 100644 --- a/packages/platform-apple-helpers/src/lib/utils/pods.ts +++ b/packages/platform-apple-helpers/src/lib/utils/pods.ts @@ -147,8 +147,11 @@ async function runPodInstall(options: { }); } catch (error) { loader.stop('Failed: Installing CocoaPods dependencies', 1); - const stderr = - (error as SubprocessError).stderr || (error as SubprocessError).output; + const fullOutput = (error as SubprocessError).output; + let errorMessage = fullOutput; + if (fullOutput.includes('### Error')) { + errorMessage = fullOutput.split('### Error')[1].trim(); + } /** * If CocoaPods failed due to repo being out of date, it will * include the update command in the error message. @@ -156,7 +159,7 @@ async function runPodInstall(options: { * `shouldHandleRepoUpdate` will be set to `false` to * prevent infinite loop (unlikely scenario) */ - if (stderr.includes('pod repo update') && shouldHandleRepoUpdate) { + if (fullOutput.includes('pod repo update') && shouldHandleRepoUpdate) { await runPodUpdate(options.sourceDir, options.useBundler); await runPodInstall({ shouldHandleRepoUpdate: false, @@ -170,7 +173,7 @@ async function runPodInstall(options: { throw new RockError( `CocoaPods installation failed. ${podErrorHelpMessage}`, - { cause: stderr }, + { cause: errorMessage }, ); } } From 1379f6e4f70a4562d485d78deeea2f27692df5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 1 Oct 2025 14:30:35 +0200 Subject: [PATCH 2/4] fixup --- .../src/lib/commands/run/getBuildSettings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts b/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts index 218e77c72..560b1d52d 100644 --- a/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts +++ b/packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts @@ -76,7 +76,7 @@ export async function getBuildSettings({ ); if (settings.length === 0) { throw new RockError( - `Failed to get build settings for your project. Looking for "app" or "framework" wrapper extension but found: ${wrapperExtension}`, + `Failed to get build settings for your project. Looking for "app" or "framework" wrapper extensions but found none.`, ); } From 86c6629d84bfbeb2720a52373305cb9653d6f489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 1 Oct 2025 14:30:50 +0200 Subject: [PATCH 3/4] changeset --- .changeset/itchy-shirts-join.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/itchy-shirts-join.md diff --git a/.changeset/itchy-shirts-join.md b/.changeset/itchy-shirts-join.md new file mode 100644 index 000000000..e819117c8 --- /dev/null +++ b/.changeset/itchy-shirts-join.md @@ -0,0 +1,5 @@ +--- +'@rock-js/platform-apple-helpers': patch +--- + +fix: run:ios with non-app targets ordered first From 75a2630f087eb2de839ec6741212e93b45d9f136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 1 Oct 2025 16:54:18 +0200 Subject: [PATCH 4/4] use stderr when no markdown --- packages/platform-apple-helpers/src/lib/utils/pods.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/platform-apple-helpers/src/lib/utils/pods.ts b/packages/platform-apple-helpers/src/lib/utils/pods.ts index 254056f37..fa6c05d78 100644 --- a/packages/platform-apple-helpers/src/lib/utils/pods.ts +++ b/packages/platform-apple-helpers/src/lib/utils/pods.ts @@ -147,8 +147,13 @@ async function runPodInstall(options: { }); } catch (error) { loader.stop('Failed: Installing CocoaPods dependencies', 1); + const stderr = (error as SubprocessError).stderr; const fullOutput = (error as SubprocessError).output; - let errorMessage = fullOutput; + let errorMessage = stderr; + /** + * CocoaPods occasionally provides a markdown template with error message. + * We don't need the part above the Error secion. + */ if (fullOutput.includes('### Error')) { errorMessage = fullOutput.split('### Error')[1].trim(); }