Skip to content

Commit 4204f5d

Browse files
committed
Add stripping to Apple libraries
1 parent f600866 commit 4204f5d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/cmake-rn/src/platforms/apple.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ export const platform: Platform<Triplet[], AppleOpts> = {
330330
async postBuild(
331331
outputPath,
332332
triplets,
333-
{ configuration, autoLink, xcframeworkExtension, target, build },
333+
{ configuration, autoLink, xcframeworkExtension, target, build, strip },
334334
) {
335335
const libraryNames = new Set<string>();
336336
const frameworkPaths: string[] = [];
337-
for (const { triplet } of triplets) {
337+
for (const { spawn, triplet } of triplets) {
338338
const buildPath = getBuildPath(build, triplet);
339339
assert(fs.existsSync(buildPath), `Expected a directory at ${buildPath}`);
340340
const sharedLibrary = await readCmakeSharedLibraryTarget(
@@ -348,10 +348,21 @@ export const platform: Platform<Triplet[], AppleOpts> = {
348348
"Expected exactly one artifact",
349349
);
350350
const [artifact] = artifacts;
351+
352+
const artifactPath = path.join(buildPath, artifact.path);
353+
354+
if (strip) {
355+
// -r: All relocation entries.
356+
// -S: All symbol table entries.
357+
// -T: All text relocation entries.
358+
// -x: All local symbols.
359+
await spawn("strip", ["-rSTx", artifactPath]);
360+
}
361+
351362
libraryNames.add(sharedLibrary.name);
352363
// Locate the path of the framework, if a free dynamic library was built
353364
if (artifact.path.includes(".framework/")) {
354-
frameworkPaths.push(path.dirname(path.join(buildPath, artifact.path)));
365+
frameworkPaths.push(path.dirname(artifactPath));
355366
} else {
356367
const libraryName = path.basename(
357368
artifact.path,

0 commit comments

Comments
 (0)