From 2447a9b7ff542edf5c0483b14805762a5ac08776 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Wed, 5 Feb 2025 17:37:51 +0100 Subject: [PATCH] fix(cli): fix Podfile having expanded symlinks This change fixes the `cap sync` command expanding symlinks in plugin paths. --- cli/src/ios/update.ts | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/cli/src/ios/update.ts b/cli/src/ios/update.ts index 83724ebe9..b1127c408 100644 --- a/cli/src/ios/update.ts +++ b/cli/src/ios/update.ts @@ -1,4 +1,4 @@ -import { copy, remove, pathExists, readFile, realpath, writeFile } from 'fs-extra'; +import { copy, remove, pathExists, readFile, writeFile } from 'fs-extra'; import { basename, dirname, join, relative } from 'path'; import c from '../colors'; @@ -73,7 +73,7 @@ export async function installCocoaPodsPlugins(config: Config, plugins: Plugin[], async function updatePodfile(config: Config, plugins: Plugin[], deployment: boolean): Promise { const dependenciesContent = await generatePodFile(config, plugins); - const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config); + const relativeCapacitoriOSPath = getRelativeCapacitoriOSPath(config); const podfilePath = join(config.ios.nativeProjectDirAbs, 'Podfile'); let podfileContent = await readFile(podfilePath, { encoding: 'utf-8' }); podfileContent = podfileContent.replace(/(def capacitor_pods)[\s\S]+?(\nend)/, `$1${dependenciesContent}$2`); @@ -110,7 +110,7 @@ async function updatePodfile(config: Config, plugins: Plugin[], deployment: bool } } -async function getRelativeCapacitoriOSPath(config: Config) { +function getRelativeCapacitoriOSPath(config: Config) { const capacitoriOSPath = resolveNode(config.app.rootDir, '@capacitor/ios', 'package.json'); if (!capacitoriOSPath) { @@ -120,24 +120,19 @@ async function getRelativeCapacitoriOSPath(config: Config) { ); } - return convertToUnixPath(relative(config.ios.nativeProjectDirAbs, await realpath(dirname(capacitoriOSPath)))); + return convertToUnixPath(relative(config.ios.nativeProjectDirAbs, dirname(capacitoriOSPath))); } async function generatePodFile(config: Config, plugins: Plugin[]): Promise { - const relativeCapacitoriOSPath = await getRelativeCapacitoriOSPath(config); - - const capacitorPlugins = plugins.filter((p) => getPluginType(p, platform) === PluginType.Core); - const pods = await Promise.all( - capacitorPlugins.map(async (p) => { - if (!p.ios) { - return ''; - } - - return ` pod '${p.ios.name}', :path => '${convertToUnixPath( - relative(config.ios.nativeProjectDirAbs, await realpath(p.rootPath)), - )}'\n`; - }), - ); + const relativeCapacitoriOSPath = getRelativeCapacitoriOSPath(config); + + const pods = plugins + .filter((p) => getPluginType(p, platform) === PluginType.Core && p.ios) + .map((p) => + ` pod '${p.ios.name}', :path => '${convertToUnixPath( + relative(config.ios.nativeProjectDirAbs, p.rootPath), + )}'\n` + ); const cordovaPlugins = plugins.filter((p) => getPluginType(p, platform) === PluginType.Cordova); cordovaPlugins.map(async (p) => { const podspecs = getPlatformElement(p, platform, 'podspec');