Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/itchy-shirts-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rock-js/platform-apple-helpers': patch
---

fix: run:ios with non-app targets ordered first
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 extensions but found none.`,
);
}

let selectedTarget = targets[0];

if (target) {
Expand All @@ -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(
Expand Down
16 changes: 12 additions & 4 deletions packages/platform-apple-helpers/src/lib/utils/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,24 @@ async function runPodInstall(options: {
});
} catch (error) {
loader.stop('Failed: Installing CocoaPods dependencies', 1);
const stderr =
(error as SubprocessError).stderr || (error as SubprocessError).output;
const stderr = (error as SubprocessError).stderr;
const fullOutput = (error as SubprocessError).output;
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();
}
/**
* If CocoaPods failed due to repo being out of date, it will
* include the update command in the error message.
*
* `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,
Expand All @@ -170,7 +178,7 @@ async function runPodInstall(options: {
throw new RockError(
`CocoaPods installation failed.
${podErrorHelpMessage}`,
{ cause: stderr },
{ cause: errorMessage },
);
}
}
Expand Down
Loading