MCPcopy
hub / github.com/ionic-team/capacitor / updatePodfile

Function updatePodfile

cli/src/ios/update.ts:320–354  ·  view source on GitHub ↗
(config: Config, plugins: Plugin[], deployment: boolean)

Source from the content-addressed store, hash-verified

318}
319
320async function updatePodfile(config: Config, plugins: Plugin[], deployment: boolean): Promise<void> {
321 const dependenciesContent = await generatePodFile(config, plugins);
322 const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config);
323 const podfilePath = join(config.ios.nativeProjectDirAbs, 'Podfile');
324 let podfileContent = await readFile(podfilePath, { encoding: 'utf-8' });
325 podfileContent = podfileContent.replace(/(def capacitor_pods)[\s\S]+?(\nend)/, `$1${dependenciesContent}$2`);
326 podfileContent = podfileContent.replace(
327 /(require_relative)[\s\S]+?(@capacitor\/ios\/scripts\/pods_helpers')/,
328 `require_relative '${relativeCapacitoriOSPath}/scripts/pods_helpers'`,
329 );
330 await writeFile(podfilePath, podfileContent, { encoding: 'utf-8' });
331
332 const podPath = await config.ios.podPath;
333 const useBundler = (await config.ios.packageManager) === 'bundler';
334 if (useBundler) {
335 await runCommand('bundle', ['exec', 'pod', 'install', ...(deployment ? ['--deployment'] : [])], {
336 cwd: config.ios.nativeProjectDirAbs,
337 });
338 } else if (await isInstalled('pod')) {
339 await runCommand(podPath, ['install', ...(deployment ? ['--deployment'] : [])], {
340 cwd: config.ios.nativeProjectDirAbs,
341 });
342 } else {
343 logger.warn('Skipping pod install because CocoaPods is not installed');
344 }
345
346 const isXcodebuildAvailable = await isInstalled('xcodebuild');
347 if (isXcodebuildAvailable) {
348 await runCommand('xcodebuild', ['-project', basename(`${config.ios.nativeXcodeProjDirAbs}`), 'clean'], {
349 cwd: config.ios.nativeProjectDirAbs,
350 });
351 } else {
352 logger.warn('Unable to find "xcodebuild". Skipping xcodebuild clean step...');
353 }
354}
355
356async function getRelativeCapacitoriOSPath(config: Config) {
357 const capacitoriOSPath = resolveNode(config.app.rootDir, '@capacitor/ios', 'package.json');

Callers 1

installCocoaPodsPluginsFunction · 0.85

Calls 6

runCommandFunction · 0.90
isInstalledFunction · 0.90
generatePodFileFunction · 0.85
readFileFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected