Skip to content

Commit 42fb62e

Browse files
committed
fixup! Dereference framework directories
1 parent 711ef56 commit 42fb62e

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
AppleTriplet as Triplet,
99
createAppleFramework,
1010
createXCframework,
11+
dereferenceDirectory,
1112
} from "react-native-node-api";
1213

1314
import type { Platform } from "./types.js";
@@ -372,6 +373,18 @@ export const platform: Platform<Triplet[], AppleOpts> = {
372373
}
373374
}
374375

376+
// Make sure none of the frameworks are symlinks
377+
// We do this before creating an xcframework to avoid symlink paths being invalidated
378+
// as the xcframework might be moved to a different location
379+
await Promise.all(
380+
frameworkPaths.map(async (frameworkPath) => {
381+
const stat = await fs.promises.lstat(frameworkPath);
382+
if (stat.isSymbolicLink()) {
383+
await dereferenceDirectory(frameworkPath);
384+
}
385+
}),
386+
);
387+
375388
const extension = xcframeworkExtension ? ".xcframework" : ".apple.node";
376389

377390
assert(
@@ -391,7 +404,6 @@ export const platform: Platform<Triplet[], AppleOpts> = {
391404
outputPath: xcframeworkOutputPath,
392405
frameworkPaths,
393406
autoLink,
394-
dereferenceFrameworkLinks: true,
395407
}),
396408
{
397409
text: `Assembling XCFramework (${libraryName})`,

packages/host/src/node/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export {
2222
determineXCFrameworkFilename,
2323
} from "./prebuilds/apple.js";
2424

25-
export { determineLibraryBasename } from "./path-utils.js";
25+
export {
26+
determineLibraryBasename,
27+
dereferenceDirectory,
28+
} from "./path-utils.js";
2629

2730
export { weakNodeApiPath } from "./weak-node-api.js";

packages/host/src/node/prebuilds/apple.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import os from "node:os";
66
import { spawn } from "@react-native-node-api/cli-utils";
77

88
import { AppleTriplet } from "./triplets.js";
9-
import {
10-
dereferenceDirectory,
11-
determineLibraryBasename,
12-
} from "../path-utils.js";
9+
import { determineLibraryBasename } from "../path-utils.js";
1310

1411
type AppleArchitecture = "arm64" | "x86_64" | "arm64;x86_64";
1512

@@ -45,7 +42,6 @@ type XCframeworkOptions = {
4542
frameworkPaths: string[];
4643
outputPath: string;
4744
autoLink: boolean;
48-
dereferenceFrameworkLinks: boolean;
4945
};
5046

5147
export async function createAppleFramework(
@@ -101,7 +97,6 @@ export async function createXCframework({
10197
frameworkPaths,
10298
outputPath,
10399
autoLink,
104-
dereferenceFrameworkLinks,
105100
}: XCframeworkOptions) {
106101
// Delete any existing xcframework to prevent the error:
107102
// - A library with the identifier 'macos-arm64' already exists.
@@ -126,17 +121,6 @@ export async function createXCframework({
126121
outputMode: "buffered",
127122
},
128123
);
129-
if (dereferenceFrameworkLinks) {
130-
// TODO: Loop over the framework directories and copy their content if they're links
131-
for await (const entry of fs.promises.glob("**/*.framework", {
132-
cwd: xcodeOutputPath,
133-
withFileTypes: true,
134-
})) {
135-
if (entry.isSymbolicLink()) {
136-
await dereferenceDirectory(path.join(entry.parentPath, entry.name));
137-
}
138-
}
139-
}
140124
if (xcodeOutputPath !== outputPath) {
141125
// Rename the xcframework to the original output path
142126
await fs.promises.rename(xcodeOutputPath, outputPath);

0 commit comments

Comments
 (0)