Skip to content

callstack-internal/with-react-native-oss-notice

Repository files navigation

with-react-native-oss-notice

Automagically generate license acknowledgements for your React Native app 🚀

Android iOS AndroidTV tvOS
Android example iOS example AndroidTV example tvOS example

Installation

yarn add with-react-native-oss-notice

or

npm i --save with-react-native-oss-notice

Usage

This tool is split into 2 parts:

  • a library that lets you display native screen with a list of all dependencies and their licenses
  • a config plugin (for Expo projects) and a custom cli plugin (for bare RN projects)

I want to generate licenses in my Expo project

  1. Add the config plugin to the app.json/app.config.js
{
  "expo": {
    "plugins": [
+      "with-react-native-oss-notice"
    ]
  }
}
  1. Set the Kotlin version for the project (might be needed for EAS)
{
  "expo": {
    "plugins": [
      "with-react-native-oss-notice"
+      [
+        "expo-build-properties",
+        {
+          "android": {
+            "kotlinVersion": "1.7.22" // <-- add a version here for resolution, version can be newer depending on the Expo SDK version used in the project 
+          }
+        }
+      ],
    ]
  }
}
  1. Use the library in the codebase
import * as React from 'react';
import { Button, View } from 'react-native';
import { WithReactNativeOSSNotice } from 'with-react-native-oss-notice';

function launchNotice() {
  WithReactNativeOSSNotice.launchLicenseListScreen('OSS Notice');
}

function MyComponent() {
  return (
    <View>
      <Button onPress={launchNotice} text="Open source licenses" />
    </View>
  );
}
  1. Use Prebuild or EAS to build the app

I want to generate licenses in my bare RN project

  1. Invoke the CLI plugin from the root of your RN app
npx react-native with-oss-notice

or

yarn react-native with-oss-notice
  1. Use the library in the codebase
import * as React from 'react';
import { Button, View } from 'react-native';
import { WithReactNativeOSSNotice } from 'with-react-native-oss-notice';

function launchNotice() {
  WithReactNativeOSSNotice.launchLicenseListScreen('OSS Notice');
}

function MyComponent() {
  return (
    <View>
      <Button onPress={launchNotice} text="Open source licenses" />
    </View>
  );
}

Expo

  • ✅ You can use this library with Development Builds by adding with-react-native-oss-notice to your app.json/app.config.js plugins array.
  • ❌ This library can't be used in the "Expo Go" app because it requires custom native code.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Acknowledgements

  • AboutLibraries - collects and displays the license metadata for the Android app <3
  • LicensePlist - generates license metadata for the iOS app <3

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published