Skip to content

Commit 5c3ee52

Browse files
committed
install pods with correct architecture
1 parent f904ece commit 5c3ee52

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

packages/cli-platform-ios/src/commands/buildIOS/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ import {BuildFlags, buildOptions} from './buildOptions';
1212
import {getConfiguration} from './getConfiguration';
1313
import {getXcodeProjectAndDir} from './getXcodeProjectAndDir';
1414
import resolvePods from '../../tools/pods';
15+
import getArchitecture from '../../tools/getArchitecture';
1516

1617
async function buildIOS(_: Array<string>, ctx: Config, args: BuildFlags) {
1718
const {xcodeProject, sourceDir} = getXcodeProjectAndDir(ctx.project.ios);
1819

20+
const isAppRunningNewArchitecture = ctx.project.ios?.sourceDir
21+
? await getArchitecture(ctx.project.ios?.sourceDir)
22+
: undefined;
23+
1924
// check if pods need to be installed
20-
await resolvePods(ctx.root, ctx.dependencies, {forceInstall: args.forcePods});
25+
await resolvePods(ctx.root, ctx.dependencies, {
26+
forceInstall: args.forcePods,
27+
newArchEnabled: isAppRunningNewArchitecture,
28+
});
2129

2230
process.chdir(sourceDir);
2331

packages/cli-platform-ios/src/tools/installPods.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,28 @@ import runBundleInstall from './runBundleInstall';
1313

1414
interface PodInstallOptions {
1515
skipBundleInstall?: boolean;
16+
newArchEnabled?: boolean;
1617
}
1718

18-
async function runPodInstall(
19-
loader: Ora,
20-
shouldHandleRepoUpdate: boolean = true,
21-
) {
19+
interface RunPodInstallOptions {
20+
shouldHandleRepoUpdate?: boolean;
21+
newArchEnabled?: boolean;
22+
}
23+
24+
async function runPodInstall(loader: Ora, options?: RunPodInstallOptions) {
25+
const shouldHandleRepoUpdate = options?.shouldHandleRepoUpdate || true;
2226
try {
2327
loader.start(
2428
`Installing CocoaPods dependencies ${chalk.dim(
2529
'(this may take a few minutes)',
2630
)}`,
2731
);
2832

29-
await execa('bundle', ['exec', 'pod', 'install']);
33+
await execa('bundle', ['exec', 'pod', 'install'], {
34+
env: {
35+
RCT_NEW_ARCH_ENABLED: options?.newArchEnabled ? '1' : '0',
36+
},
37+
});
3038
} catch (error) {
3139
// "pod" command outputs errors to stdout (at least some of them)
3240
const stderr = (error as any).stderr || (error as any).stdout;
@@ -40,7 +48,10 @@ async function runPodInstall(
4048
*/
4149
if (stderr.includes('pod repo update') && shouldHandleRepoUpdate) {
4250
await runPodUpdate(loader);
43-
await runPodInstall(loader, false);
51+
await runPodInstall(loader, {
52+
shouldHandleRepoUpdate: false,
53+
newArchEnabled: options?.newArchEnabled,
54+
});
4455
} else {
4556
loader.fail();
4657
logger.error(stderr);
@@ -143,7 +154,7 @@ async function installPods(
143154
await installCocoaPods(loader);
144155
}
145156

146-
await runPodInstall(loader);
157+
await runPodInstall(loader, {newArchEnabled: options?.newArchEnabled});
147158
} finally {
148159
process.chdir('..');
149160
}

packages/cli-platform-ios/src/tools/pods.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616

1717
interface ResolvePodsOptions {
1818
forceInstall?: boolean;
19+
newArchEnabled?: boolean;
1920
}
2021

2122
interface NativeDependencies {
@@ -114,11 +115,25 @@ export default async function resolvePods(
114115
!compareMd5Hashes(currentDependenciesHash, cachedDependenciesHash) ||
115116
!arePodsInstalled
116117
) {
117-
await install(
118-
packageJson,
119-
cachedDependenciesHash,
120-
currentDependenciesHash,
121-
iosFolderPath,
122-
);
118+
const loader = getLoader('Installing CocoaPods...');
119+
try {
120+
await installPods(loader, {
121+
skipBundleInstall: !!cachedDependenciesHash,
122+
newArchEnabled: options?.newArchEnabled,
123+
});
124+
cacheManager.set(
125+
packageJson.name,
126+
'dependencies',
127+
currentDependenciesHash,
128+
);
129+
loader.succeed();
130+
} catch {
131+
loader.fail();
132+
throw new CLIError(
133+
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
134+
'pod install',
135+
)} manually`,
136+
);
137+
}
123138
}
124139
}

0 commit comments

Comments
 (0)