Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to plain pod if Gemfile does not contain CocoaPods #6581

Merged
merged 7 commits into from
May 9, 2023
Merged
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
36 changes: 25 additions & 11 deletions cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,18 @@ async function determineGemfileOrCocoapodPath(
return process.env.CAPACITOR_COCOAPODS_PATH;
}

// Look for 'Gemfile' in app directories
const appSpecificGemfileExists =
(await pathExists(resolve(rootDir, 'Gemfile'))) ||
(await pathExists(resolve(platformDir, 'Gemfile'))) ||
(await pathExists(resolve(nativeProjectDirAbs, 'Gemfile')));
let gemfilePath = '';
if (await pathExists(resolve(rootDir, 'Gemfile'))) {
gemfilePath = resolve(rootDir, 'Gemfile');
} else if (await pathExists(resolve(platformDir, 'Gemfile'))) {
gemfilePath = resolve(platformDir, 'Gemfile');
} else if (await pathExists(resolve(nativeProjectDirAbs, 'Gemfile'))) {
gemfilePath = resolve(nativeProjectDirAbs, 'Gemfile');
}

const appSpecificGemfileExists = gemfilePath != '';

// Multi-app projects might share a single global 'Gemfile' at the Git repository root directory.
let globalGemfileExists = false;
if (!appSpecificGemfileExists) {
try {
const output = await getCommandOutput(
Expand All @@ -462,16 +466,26 @@ async function determineGemfileOrCocoapodPath(
{ cwd: rootDir },
);
if (output != null) {
globalGemfileExists = await pathExists(resolve(output, 'Gemfile'));
gemfilePath = resolve(output, 'Gemfile');
}
} catch (e) {
} catch (e: any) {
// Nothing
}
}

if (appSpecificGemfileExists || globalGemfileExists) {
return 'bundle exec pod';
} else {
try {
const gemfileText = (await readFile(gemfilePath)).toString();
if (!gemfileText) {
return 'pod';
}
const cocoapodsInGemfile = new RegExp(/gem 'cocoapods'/).test(gemfileText);

if (cocoapodsInGemfile) {
return 'bundle exec pod';
} else {
return 'pod';
}
} catch {
return 'pod';
}
}
Expand Down