Skip to content

Commit 1a2730e

Browse files
committed
Loading framework from @rpath
1 parent 6814c4a commit 1a2730e

File tree

2 files changed

+9
-6
lines changed
  • packages
    • react-native-node-api-cmake/src
    • react-native-node-api-modules/src/bindings-polyfill

2 files changed

+9
-6
lines changed

packages/react-native-node-api-cmake/src/apple.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ export function createFramework(libraryPath: string) {
128128
const newLibraryPath = path.join(frameworkPath, libraryName);
129129
fs.renameSync(libraryPath, newLibraryPath);
130130
// Update the name of the library
131-
// cp.spawnSync("install_name_tool", [
132-
// "-id",
133-
// `@rpath/${libraryName}`,
134-
// newLibraryPath,
135-
// ]);
131+
cp.spawnSync("install_name_tool", [
132+
"-id",
133+
`@rpath/${libraryName}.framework/${libraryName}`,
134+
newLibraryPath,
135+
]);
136136
return frameworkPath;
137137
}
138138

@@ -161,6 +161,7 @@ export function createXCframework({
161161
);
162162
assert.equal(status, 0, "Failed to create xcframework");
163163
// Write a file to mark the xcframework is a Node-API module
164+
// TODO: Consider including this in the Info.plist file instead
164165
fs.writeFileSync(
165166
path.join(outputPath, "react-native-node-api-module"),
166167
"",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { requireNodeAddon } from "../host";
22

33
function binding(moduleName: string): unknown {
4-
return requireNodeAddon(moduleName);
4+
// Strip ".node" suffix
5+
moduleName = moduleName.replace(/\.node$/g, "");
6+
return requireNodeAddon(`@rpath/${moduleName}.framework/${moduleName}`);
57
}
68

79
export = binding;

0 commit comments

Comments
 (0)