Skip to content

Commit

Permalink
fix(ios): create headers directory if it doesn't exist, write a keep …
Browse files Browse the repository at this point in the history
…file to ensure it persists (#12996)

Fixes TIMOB-28511
  • Loading branch information
ewanharris committed Aug 26, 2021
1 parent f7e9fb8 commit c1a6410
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions iphone/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,15 @@ iOSModuleBuilder.prototype.createUniversalBinary = function createUniversalBinar
this.logger.error(err.trim() + '\n');
process.exit(1);
}

// Ensure that each Headers directory contains a file to keep it around in source control
for (const dir of fs.readdirSync(xcframeworkDest)) {
const headersPath = path.join(xcframeworkDest, dir, 'Headers');

if (fs.existsSync(headersPath) && fs.readdirSync(headerPath).length === 0) {
fs.writeFileSync(path.join(headersPath, `.${moduleId}-keep`), 'This file is to ensure the Headers directory gets checked into source control');
}
}
next();
}.bind(this));
};
Expand Down
12 changes: 12 additions & 0 deletions iphone/cli/hooks/frameworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,17 @@ class FrameworkInspector {
libInfo.SupportedArchitectures.forEach(a => archs.add(a));
supportedPlatforms.add(libInfo.SupportedPlatform); // should always be 'ios'
}

// Ensure that each Headers directory contains a file to keep it around in source control
if (libInfo.HeadersPath) {
const headersDirectory = path.join(frameworkPath, libInfo.LibraryIdentifier, libInfo.HeadersPath);

if (!await fs.pathExists(headersDirectory)) {
this._logger.debug(`Creating ${headersDirectory} and writing .keep file to it`);
await fs.mkdir(headersDirectory);
await fs.writeFile(path.join(headersDirectory, `.${frameworkName}-keep`), 'This file is to ensure the Headers directory gets checked into source control');
}
}
}
meta.type = type;
meta.architectures = archs;
Expand All @@ -808,6 +819,7 @@ class FrameworkInspector {
}
const archs = Array.from(frameworkInfo.architectures.values()).join(', ');
this._logger.debug(`Found framework ${frameworkName.green} (type: ${type}, archs: ${archs}) at ${frameworkPath.cyan}`);

return frameworkInfo;
}

Expand Down

0 comments on commit c1a6410

Please sign in to comment.