Skip to content

Commit 6aa1320

Browse files
fix(apple): fallback to pod install when installing with bundle fails (#200)
* fix(apple): fallback to `pod install` when installing with `bundle` fails * chore: adjust comment * chore: add changeset * fix: use `useBundler`
1 parent ae36943 commit 6aa1320

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

.changeset/loud-walls-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rnef/platform-apple-helpers': patch
3+
---
4+
5+
Fallback to `pod install` when installing with `bundle exec pod install` fails

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ async function runPodInstall(options: {
9494

9595
const shouldHandleRepoUpdate = options?.shouldHandleRepoUpdate || true;
9696
const loader = spinner({ indicator: 'timer' });
97+
loader.start('Installing CocoaPods dependencies');
98+
99+
const command = options.useBundler ? 'bundle' : 'pod';
100+
const args = options.useBundler ? ['exec', 'pod', 'install'] : ['install'];
101+
97102
try {
98-
loader.start('Installing CocoaPods dependencies');
99-
const command = options.useBundler ? 'bundle' : 'pod';
100-
const args = options.useBundler ? ['exec', 'pod', 'install'] : ['install'];
101103
await spawn(command, args, {
102104
env: {
103105
RCT_NEW_ARCH_ENABLED: options.newArch ? '1' : '0',
@@ -127,13 +129,23 @@ async function runPodInstall(options: {
127129
useBundler: options.useBundler,
128130
});
129131
} else {
130-
loader.stop('CocoaPods installation failed. ', 1);
132+
if (options.useBundler) {
133+
// If for any reason the installing with bundler failed, try with pure `pod install`
134+
await runPodInstall({
135+
shouldHandleRepoUpdate: false,
136+
sourceDir: options.sourceDir,
137+
newArch: options.newArch,
138+
useBundler: false,
139+
});
140+
} else {
141+
loader.stop('CocoaPods installation failed. ', 1);
131142

132-
throw new RnefError(
133-
`CocoaPods installation failed. Please make sure your environment is correctly set up.
143+
throw new RnefError(
144+
`CocoaPods installation failed. Please make sure your environment is correctly set up.
134145
Learn more at: ${color.dim('https://cocoapods.org/')}`,
135-
{ cause: stderr }
136-
);
146+
{ cause: stderr }
147+
);
148+
}
137149
}
138150
}
139151

0 commit comments

Comments
 (0)