From ca14aa19cc6c63da654097c1f29e4e933317b46d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Fri, 9 Oct 2026 10:46:02 +0200 Subject: [PATCH] Remove automatic addon linking --- README.md | 33 +++++++++++++++++++++++++++++++++ android/build.gradle | 6 ------ android/link.mjs | 12 ------------ ios/BareKit.podspec | 18 ------------------ ios/link.mjs | 12 ------------ package.json | 1 - react-native-bare-kit.podspec | 18 ------------------ 7 files changed, 33 insertions(+), 67 deletions(-) delete mode 100644 android/link.mjs delete mode 100644 ios/link.mjs diff --git a/README.md b/README.md index 423c3d6..c59d1e7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,39 @@ worklet.start('/app.bundle', source) Refer to for an example of using the library in an Expo application. +### Linking native addons + +Native addons used by the worklet are not linked automatically. Applications must link them into their native projects themselves, such as by using . Given the entry point of the worklet, `bare-link` links the addons loaded by its module graph: + +```console +bare-link --preset ios --out ios/addons worklet.js +bare-link --preset android --out android/app/src/main/jniLibs worklet.js +``` + +On iOS, the resulting `.xcframework` bundles must be embedded in the application target. On Android, the resulting `.so` libraries must be included in the `jniLibs` of the application and the resulting `.jar` libraries, if any, added as dependencies. + +As a convenience, the library includes designated directories that are already wired into its native projects. Any `.xcframework` bundle in `ios/addons` and any `.so` or `.jar` library in `android/src/main/addons` of the library will be included in the build without further configuration: + +```console +bare-link --preset ios --out node_modules/react-native-bare-kit/ios/addons worklet.js +bare-link --preset android --out node_modules/react-native-bare-kit/android/src/main/addons worklet.js +``` + +As these directories live within `node_modules`, they are cleared whenever the library is reinstalled. Consider running the commands from a `postinstall` script of the application: + +```json +{ + "scripts": { + "postinstall": "npm run link:ios && npm run link:android", + "link:ios": "bare-link --preset ios --out node_modules/react-native-bare-kit/ios/addons worklet.js", + "link:android": "bare-link --preset android --out node_modules/react-native-bare-kit/android/src/main/addons worklet.js" + }, + "devDependencies": { + "bare-link": "^4.0.1" + } +} +``` + ### Logging The `console.*` logging APIs used in the worklet write to the system log using with the `bare` identifier. Refer to for instructions on how to consume the logs. diff --git a/android/build.gradle b/android/build.gradle index d4ff633..50974b2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,12 +47,6 @@ android { } } -task link(type: Exec) { - commandLine "node", "link.mjs" -} - -preBuild.dependsOn link - repositories { google() mavenCentral() diff --git a/android/link.mjs b/android/link.mjs deleted file mode 100644 index 0d603ca..0000000 --- a/android/link.mjs +++ /dev/null @@ -1,12 +0,0 @@ -import path from 'path' -import { fileURLToPath } from 'url' -import link from 'bare-link' - -const __filename = fileURLToPath(import.meta.url) - -for await (const resource of link(path.join(__filename, '..', '..', '..', '..'), { - hosts: ['android-arm64', 'android-arm', 'android-ia32', 'android-x64'], - out: path.join(__filename, '..', 'src', 'main', 'addons') -})) { - console.log('Wrote', resource) -} diff --git a/ios/BareKit.podspec b/ios/BareKit.podspec index aa34e00..7121b39 100644 --- a/ios/BareKit.podspec +++ b/ios/BareKit.podspec @@ -2,16 +2,6 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "../package.json"))) -begin - lockfile = File.read(File.join(__dir__, "../../../package-lock.json")) -rescue - begin - lockfile = File.read(File.join(__dir__, "../../../yarn.lock")) - rescue - lockfile = nil - end -end - Pod::Spec.new do |s| s.name = "BareKit" s.version = package["version"] @@ -25,13 +15,5 @@ Pod::Spec.new do |s| s.source = { :git => package["repository"]["url"], :tag => "#{s.version}" } s.vendored_frameworks = "*.xcframework", "addons/*.xcframework" - - s.prepare_command = "node link.mjs" - - if lockfile - sum = Digest::SHA256.hexdigest lockfile - - s.version = "#{s.version}+#{sum[0, 6]}" - end end diff --git a/ios/link.mjs b/ios/link.mjs deleted file mode 100644 index 44124a2..0000000 --- a/ios/link.mjs +++ /dev/null @@ -1,12 +0,0 @@ -import path from 'path' -import { fileURLToPath } from 'url' -import link from 'bare-link' - -const __filename = fileURLToPath(import.meta.url) - -for await (const resource of link(path.join(__filename, '..', '..', '..', '..'), { - hosts: ['ios-arm64', 'ios-arm64-simulator', 'ios-x64-simulator'], - out: path.join(__filename, '..', 'addons') -})) { - console.log('Wrote', resource) -} diff --git a/package.json b/package.json index af68841..307f8f8 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ }, "dependencies": { "bare-events": "^2.6.1", - "bare-link": "^3.0.1", "streamx": "^2.21.0" }, "peerDependencies": { diff --git a/react-native-bare-kit.podspec b/react-native-bare-kit.podspec index fd4cfd3..a4be2b0 100644 --- a/react-native-bare-kit.podspec +++ b/react-native-bare-kit.podspec @@ -2,16 +2,6 @@ require "json" package = JSON.parse(File.read(File.join(__dir__, "package.json"))) -begin - lockfile = File.read(File.join(__dir__, "../../package-lock.json")) -rescue - begin - lockfile = File.read(File.join(__dir__, "../../yarn.lock")) - rescue - lockfile = nil - end -end - Pod::Spec.new do |s| s.name = package["name"] s.version = package["version"] @@ -32,13 +22,5 @@ Pod::Spec.new do |s| s.module_name = "react_native_bare_kit" - s.prepare_command = "node ios/link.mjs" - install_modules_dependencies(s) - - if lockfile - sum = Digest::SHA256.hexdigest lockfile - - s.version = "#{s.version}+#{sum[0, 6]}" - end end