Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@ worklet.start('/app.bundle', source)

Refer to <https://github.com/holepunchto/bare-expo> 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 <https://github.com/holepunchto/bare-link>. 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 <https://github.com/holepunchto/liblog> with the `bare` identifier. Refer to <https://github.com/holepunchto/liblog#consuming-logs> for instructions on how to consume the logs.
Expand Down
6 changes: 0 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ android {
}
}

task link(type: Exec) {
commandLine "node", "link.mjs"
}

preBuild.dependsOn link

repositories {
google()
mavenCentral()
Expand Down
12 changes: 0 additions & 12 deletions android/link.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions ios/BareKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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

12 changes: 0 additions & 12 deletions ios/link.mjs

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
},
"dependencies": {
"bare-events": "^2.6.1",
"bare-link": "^3.0.1",
"streamx": "^2.21.0"
},
"peerDependencies": {
Expand Down
18 changes: 0 additions & 18 deletions react-native-bare-kit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Loading