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

feat(cli): add support for 'pod install' in VM based environments #5144

Merged
merged 13 commits into from
Oct 27, 2021
Merged
11 changes: 0 additions & 11 deletions cli/src/ios/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,3 @@ export async function editProjectSettingsIOS(config: Config): Promise<void> {
await writeFile(plistPath, plistContent, { encoding: 'utf-8' });
await writeFile(pbxPath, pbxContent, { encoding: 'utf-8' });
}

export function shouldPodInstall(
config: Config,
platformName: string,
): boolean {
// Don't run pod install or xcodebuild if not on macOS
if (config.cli.os !== OS.Mac && platformName === 'ios') {
return false;
}
return true;
}
65 changes: 36 additions & 29 deletions cli/src/ios/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import type { Plugin } from '../plugin';
import { copy as copyTask } from '../tasks/copy';
import { convertToUnixPath } from '../util/fs';
import { resolveNode } from '../util/node';
import { runCommand } from '../util/subprocess';
import { runCommand, isInstalled } from '../util/subprocess';
import { extractTemplate } from '../util/template';

import { getIOSPlugins, shouldPodInstall } from './common';
import { getIOSPlugins } from './common';

const platform = 'ios';

Expand Down Expand Up @@ -79,18 +79,14 @@ export async function installCocoaPodsPlugins(
plugins: Plugin[],
deployment: boolean,
): Promise<void> {
if (shouldPodInstall(config, platform)) {
await runTask(
`Updating iOS native dependencies with ${c.input(
`${config.ios.podPath} install`,
)}`,
() => {
return updatePodfile(config, plugins, deployment);
},
);
} else {
logger.warn('Skipping pod install on unsupported OS');
}
await runTask(
`Updating iOS native dependencies with ${c.input(
`${config.ios.podPath} install`,
)}`,
() => {
return updatePodfile(config, plugins, deployment);
},
);
}

async function updatePodfile(
Expand All @@ -108,23 +104,34 @@ async function updatePodfile(
);
await writeFile(podfilePath, podfileContent, { encoding: 'utf-8' });

if (!deployment) {
await remove(podfileLockPath);
const podCommandExists = await isInstalled('pod');
if (podCommandExists) {
if (!deployment) {
await remove(podfileLockPath);
}
await runCommand(
config.ios.podPath,
['install', ...(deployment ? ['--deployment'] : [])],
{ cwd: config.ios.nativeProjectDirAbs },
);
} else {
logger.warn('Skipping pod install because CocoaPods is not installed');
}

await runCommand(
config.ios.podPath,
['install', ...(deployment ? ['--deployment'] : [])],
{ cwd: config.ios.nativeProjectDirAbs },
);

await runCommand(
'xcodebuild',
['-project', basename(`${config.ios.nativeXcodeProjDirAbs}`), 'clean'],
{
cwd: config.ios.nativeProjectDirAbs,
},
);
const isXcodebuildAvailable = await isInstalled('xcodebuild');
if (isXcodebuildAvailable) {
await runCommand(
'xcodebuild',
['-project', basename(`${config.ios.nativeXcodeProjDirAbs}`), 'clean'],
{
cwd: config.ios.nativeProjectDirAbs,
},
);
} else {
logger.warn(
'Unable to find "xcodebuild". Skipping xcodebuild clean step...',
);
}
}

async function generatePodFile(
Expand Down