diff --git a/docs/src/guides/publishing.md b/docs/src/guides/publishing.md index 52a5de74..1ff5a42e 100644 --- a/docs/src/guides/publishing.md +++ b/docs/src/guides/publishing.md @@ -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 @@ -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