|
1 | 1 | # Prebuilds |
2 | 2 |
|
3 | | -This document will codify the naming and directory structure of prebuilt binaries, expected by the `react-native-node-api-modules` package and tools. |
| 3 | +This document codifies the naming and directory structure of prebuilt binaries, expected by the auto-linking mechanism. |
4 | 4 |
|
5 | | -To align with prior art and established patterns around the distribution of Node-API modules for Node.js (and other engines supporting this), |
| 5 | +At the time of writing, our auto-linking host package (`react-native-node-api-modules`) support two kinds of prebuilds: |
6 | 6 |
|
7 | | -## Apple: XCFrameworks of dynamic libraries in frameworks |
| 7 | +## `*.android.node` (for Android) |
| 8 | + |
| 9 | +A jniLibs-like directory structure of CPU-architecture specific directories containing a single `.so` library file. |
| 10 | + |
| 11 | +The name of all the `.so` library files: |
| 12 | + |
| 13 | +- must be the same across all CPU-architectures |
| 14 | +- can have a "lib" prefix, but doesn't have to |
| 15 | +- must have an `.so` or `.node` file extension |
| 16 | + |
| 17 | +> [!NOTE] |
| 18 | +> The `SONAME` doesn't have to match and is not updated as the .so is copied into the host package. |
| 19 | +> This might cause trouble if you're trying to link with the library from other native code. |
| 20 | +> We're tracking [#14](https://github.com/callstackincubator/react-native-node-api-modules/issues/14) to fix this 🤞 |
| 21 | +
|
| 22 | +The directory must have a `react-native-node-api-module` file (the content doesn't matter), to signal that the directory is intended for auto-linking by the `react-native-node-api-module` package. |
| 23 | + |
| 24 | +## `*.apple.node` (for Apple) |
| 25 | + |
| 26 | +An XCFramework of dynamic libraries wrapped in `.framework` bundles, renamed from `.xcframework` to `.apple.node` to ease discoverability. |
8 | 27 |
|
9 | 28 | The Apple Developer documentation on ["Creating a multiplatform binary framework bundle"](https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle#Avoid-issues-when-using-alternate-build-systems) mentions: |
10 | 29 |
|
11 | 30 | > An XCFramework can include dynamic library files, but only macOS supports these libraries for dynamic linking. Dynamic linking on iOS, watchOS, and tvOS requires the XCFramework to contain .framework bundles. |
12 | 31 |
|
13 | | -<!-- TODO: Write this --> |
| 32 | +The directory must have a `react-native-node-api-module` file (the content doesn't matter), to signal that the directory is intended for auto-linking by the `react-native-node-api-module` package. |
| 33 | + |
| 34 | +## Why did we choose this naming scheme? |
14 | 35 |
|
15 | | -## Android: Directory of architecture specific directories of shared object library files. |
| 36 | +To align with prior art and established patterns around the distribution of Node-API modules for Node.js, we've chosen to use the ".node" filename extension for prebuilds of Node-API modules, targeting React Native. |
16 | 37 |
|
17 | | -<!-- TODO: Write this --> |
| 38 | +To enable distribution of packages with multiple co-existing platform-specific prebuilts, we've chosen to lean into the pattern of platform-specific filename extensions, used by the Metro bundler. |
0 commit comments