Skip to content

Commit

Permalink
Expand publishing docs (#130)
Browse files Browse the repository at this point in the history
Fixes: #121

I should add that my own understanding of the npm publishing process
isn't super extensive. So this will probably benefit from improvement in
the future.

One thing I thought about when writing this up: If we could get UBRN to
output the `.xcframework` into the `/ios` folder, the default
`.gitignore` and `package.json` that `create-react-native-library`
generates might actually be sufficient without any modifications.

---------

Co-authored-by: jhugman <[email protected]>
  • Loading branch information
Johennes and jhugman authored Oct 16, 2024
1 parent d25da35 commit fb6c2ef
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions docs/src/guides/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ I would love some [help with this document](../contributing/documentation.md).

## Binary builds

In order to distribute pre-built packages you will need to add to `.gitignore` the built `.a`:
You likely don't want to track pre-built binaries in your git repository but you may want to include them in published packages. If so, you will have to work around `npm`'s behaviour of factoring in `.gitignore` when picking files to include in packages.

One way to do this is by using the `files` array in `package.json`. The steps to achieve this will depend on the particular contents of your repository. For illustration purposes, let's assume you're ignoring binaries in `.gitignore` with

```
build/
*.a
```

To include the libraries in `/build/$library.xcframework` and `/android/src/main/jniLibs/$target/$library.a` in your npm package, you can add the following to `package.json`:

```diff
# From uniffi-bindgen-react-native
rust_modules/
+*.a
"files": [
+ "android",
+ "build",
```

but add them back in to the `files` section of `package.json`[^issue121].
Another option is to create an `.npmignore` file. This will require you to duplicate most of the contents of `.gitignore` though and might create issues if you forget to duplicate entries as you add them later.

[^issue121]: [This advice](https://github.com/jhugman/uniffi-bindgen-react-native/issues/121) is from @Johennes
In either case, it's good practice to run `npm pack --dry-run` and verify the package contents before publishing.

## Source packages

Expand All @@ -32,7 +41,7 @@ scripts: {
"ubrn:ios": "ubrn build ios --config ubrn.config.yaml --and-generate && (cd example/ios && pod install)",
"ubrn:android": "ubrn build android --config ubrn.config.yaml --and-generate",
"ubrn:checkout": "ubrn checkout --config ubrn.config.yaml",
+ "postinstall": "yarn ubrn:checkout && yarn ubrn:android && yarn ubrn:ios",
+ "postinstall": "yarn ubrn:checkout && yarn ubrn:android --release && yarn ubrn:ios --release",
```

## Add `uniffi-bindgen-react-native` to your README.md
Expand Down

0 comments on commit fb6c2ef

Please sign in to comment.