Skip to content

Commit 3930008

Browse files
fix: remove hardcoded path to iOS folder (#2111)
* fix: use dynamic path to `ios` folder * fix: change parameters order
1 parent 36d00ea commit 3930008

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/cli-platform-ios/src/tools/installPods.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ async function installCocoaPods(loader: Ora) {
110110
}
111111
}
112112

113-
async function installPods(loader?: Ora, options?: PodInstallOptions) {
113+
async function installPods(
114+
loader?: Ora,
115+
iosFolderPath?: string,
116+
options?: PodInstallOptions,
117+
) {
114118
loader = loader || new NoopLoader();
115119
try {
116-
if (!fs.existsSync('ios')) {
120+
if (!iosFolderPath && !fs.existsSync('ios')) {
117121
return;
118122
}
119123

120-
process.chdir('ios');
124+
process.chdir(iosFolderPath ?? 'ios');
121125

122126
const hasPods = fs.existsSync('Podfile');
123127

packages/cli-platform-ios/src/tools/pods.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ async function install(
6161
packageJson: Record<string, any>,
6262
cachedDependenciesHash: string | undefined,
6363
currentDependenciesHash: string,
64+
iosFolderPath: string,
6465
) {
6566
const loader = getLoader('Installing CocoaPods...');
6667
try {
67-
await installPods(loader, {skipBundleInstall: !!cachedDependenciesHash});
68+
await installPods(loader, iosFolderPath, {
69+
skipBundleInstall: !!cachedDependenciesHash,
70+
});
6871
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
6972
loader.succeed();
7073
} catch {
@@ -98,14 +101,24 @@ export default async function resolvePods(
98101
);
99102

100103
if (options?.forceInstall) {
101-
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
104+
await install(
105+
packageJson,
106+
cachedDependenciesHash,
107+
currentDependenciesHash,
108+
iosFolderPath,
109+
);
102110
} else if (arePodsInstalled && cachedDependenciesHash === undefined) {
103111
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
104112
} else if (
105113
!cachedDependenciesHash ||
106114
!compareMd5Hashes(currentDependenciesHash, cachedDependenciesHash) ||
107115
!arePodsInstalled
108116
) {
109-
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
117+
await install(
118+
packageJson,
119+
cachedDependenciesHash,
120+
currentDependenciesHash,
121+
iosFolderPath,
122+
);
110123
}
111124
}

0 commit comments

Comments
 (0)