Skip to content

Commit 91e1f35

Browse files
committed
fix: run:ios with non-app targets ordered first
1 parent 94e2fba commit 91e1f35

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

packages/platform-apple-helpers/src/lib/commands/run/getBuildSettings.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function getBuildSettings({
3939
? getSimulatorPlatformSDK(platformName)
4040
: getDevicePlatformSDK(platformName);
4141

42-
const { stdout: buildSettings } = await spawn(
42+
const { stdout: buildSettingsOutput } = await spawn(
4343
'xcodebuild',
4444
[
4545
xcodeProject.isWorkspace ? '-workspace' : '-project',
@@ -64,13 +64,22 @@ export async function getBuildSettings({
6464
action: string;
6565
buildSettings: BuildSettings;
6666
target: string;
67-
}[] = JSON.parse(buildSettings).filter(
68-
({ target }: { target: string }) =>
69-
target !== 'React' && target !== 'React-Core',
67+
}[] = JSON.parse(buildSettingsOutput).filter(
68+
({
69+
buildSettings: { WRAPPER_EXTENSION },
70+
}: {
71+
buildSettings: BuildSettings;
72+
}) => WRAPPER_EXTENSION === 'app' || WRAPPER_EXTENSION === 'framework',
7073
);
7174
const targets = settings.map(
7275
({ target: settingsTarget }: { target: string }) => settingsTarget,
7376
);
77+
if (settings.length === 0) {
78+
throw new RockError(
79+
`Failed to get build settings for your project. Looking for "app" or "framework" wrapper extension but found: ${wrapperExtension}`,
80+
);
81+
}
82+
7483
let selectedTarget = targets[0];
7584

7685
if (target) {
@@ -89,31 +98,21 @@ export async function getBuildSettings({
8998

9099
// Find app in all building settings - look for WRAPPER_EXTENSION: 'app',
91100
const targetIndex = targets.indexOf(selectedTarget);
92-
const targetSettings = settings[targetIndex].buildSettings;
93-
94-
const wrapperExtension = targetSettings.WRAPPER_EXTENSION;
95-
96-
if (wrapperExtension === 'app' || wrapperExtension === 'framework') {
97-
const buildSettings = settings[targetIndex].buildSettings;
98-
99-
if (!buildSettings) {
100-
throw new RockError('Failed to get build settings for your project');
101-
}
102-
103-
const appPath = getBuildPath(buildSettings, platformName);
104-
const infoPlistPath = buildSettings.INFOPLIST_PATH;
105-
const targetBuildDir = buildSettings.TARGET_BUILD_DIR;
101+
const buildSettings = settings[targetIndex].buildSettings;
106102

107-
return {
108-
appPath,
109-
infoPlistPath: path.join(targetBuildDir, infoPlistPath),
110-
bundleIdentifier: buildSettings.PRODUCT_BUNDLE_IDENTIFIER,
111-
};
103+
if (!buildSettings) {
104+
throw new RockError('Failed to get build settings for your project');
112105
}
113106

114-
throw new RockError(
115-
`Failed to get build settings for your project. Looking for "app" or "framework" wrapper extension but found: ${wrapperExtension}`,
116-
);
107+
const appPath = getBuildPath(buildSettings, platformName);
108+
const infoPlistPath = buildSettings.INFOPLIST_PATH;
109+
const targetBuildDir = buildSettings.TARGET_BUILD_DIR;
110+
111+
return {
112+
appPath,
113+
infoPlistPath: path.join(targetBuildDir, infoPlistPath),
114+
bundleIdentifier: buildSettings.PRODUCT_BUNDLE_IDENTIFIER,
115+
};
117116
}
118117

119118
function getBuildPath(

packages/platform-apple-helpers/src/lib/utils/pods.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,19 @@ async function runPodInstall(options: {
147147
});
148148
} catch (error) {
149149
loader.stop('Failed: Installing CocoaPods dependencies', 1);
150-
const stderr =
151-
(error as SubprocessError).stderr || (error as SubprocessError).output;
150+
const fullOutput = (error as SubprocessError).output;
151+
let errorMessage = fullOutput;
152+
if (fullOutput.includes('### Error')) {
153+
errorMessage = fullOutput.split('### Error')[1].trim();
154+
}
152155
/**
153156
* If CocoaPods failed due to repo being out of date, it will
154157
* include the update command in the error message.
155158
*
156159
* `shouldHandleRepoUpdate` will be set to `false` to
157160
* prevent infinite loop (unlikely scenario)
158161
*/
159-
if (stderr.includes('pod repo update') && shouldHandleRepoUpdate) {
162+
if (fullOutput.includes('pod repo update') && shouldHandleRepoUpdate) {
160163
await runPodUpdate(options.sourceDir, options.useBundler);
161164
await runPodInstall({
162165
shouldHandleRepoUpdate: false,
@@ -170,7 +173,7 @@ async function runPodInstall(options: {
170173
throw new RockError(
171174
`CocoaPods installation failed.
172175
${podErrorHelpMessage}`,
173-
{ cause: stderr },
176+
{ cause: errorMessage },
174177
);
175178
}
176179
}

0 commit comments

Comments
 (0)