Skip to content

Commit 60a7b36

Browse files
committed
fix(ios): guard modulemap generation against missing headers dir
A plugin can ship a static lib (.a) without an include/{lib} headers folder. Check the headers dir exists before readDirectory so we bail out gracefully (clean up any stale modulemap, return false) instead of throwing. Addresses PR review feedback.
1 parent 1cb741c commit 60a7b36

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/services/ios-project-service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,18 @@ export class IOSProjectService
17361736
libraryName: string,
17371737
modulemapDir: string,
17381738
): boolean {
1739+
const modulemapPath = path.join(modulemapDir, "module.modulemap");
1740+
1741+
// A plugin may ship a `.a` without an `include/{lib}` headers folder. In
1742+
// that case there's nothing to expose as a module - clean up any stale
1743+
// modulemap and bail out instead of letting readDirectory throw.
1744+
if (!this.$fs.exists(headersFolderPath)) {
1745+
if (this.$fs.exists(modulemapPath)) {
1746+
this.$fs.deleteFile(modulemapPath);
1747+
}
1748+
return false;
1749+
}
1750+
17391751
const headersFilter = (fileName: string, containingFolderPath: string) =>
17401752
path.extname(fileName) === ".h" &&
17411753
this.$fs.getFsStats(path.join(containingFolderPath, fileName)).isFile();
@@ -1744,8 +1756,6 @@ export class IOSProjectService
17441756
headersFilter(item, headersFolderPath),
17451757
);
17461758

1747-
const modulemapPath = path.join(modulemapDir, "module.modulemap");
1748-
17491759
if (!headerFiles.length) {
17501760
if (this.$fs.exists(modulemapPath)) {
17511761
this.$fs.deleteFile(modulemapPath);

0 commit comments

Comments
 (0)