cli icon indicating copy to clipboard operation
cli copied to clipboard

feat: add `add-platform` command

Open szymonrybczak opened this issue 6 months ago • 4 comments

Summary:

In this Pull Request I've added new command add-platform which re-uses code from init command to add a new OOT platform to existing React Native app. It gets React Native version from package.json and it tries to find a matching platform's version from NPM registry. Then, if successful it reuses editTemplate functions to replace placeholders.

https://github.com/react-native-community/cli/assets/63900941/6529cf35-f27a-4373-b843-1dc4bf66b4c7

For OOT platforms to add a compatibility with the new command:

  1. Add platforms inside template.config.js, which is an array in which OOT platform should provide names of folders containing native code. e.g. platforms: ["macos"]
  2. Add postInitScript (also under template.config.js) with e.g. installing Pods and printing run instructions.
  3. Add platform's specific native code under packages/react-native/template${platformName}.

Checklist

  • [x] Documentation is up to date to reflect these changes.
  • [x] Follows commit message convention described in CONTRIBUTING.md

szymonrybczak avatar Feb 14 '24 13:02 szymonrybczak