react-native-test-app icon indicating copy to clipboard operation
react-native-test-app copied to clipboard

feat: add support for `@expo/config-plugins`

Open tido64 opened this issue 3 years ago • 0 comments

Description

Adds support for @expo/config-plugins. Support is currently limited to Android and iOS.

Platforms affected

  • [x] Android
  • [x] iOS
  • [ ] macOS
  • [ ] Windows

Test plan

First, we need to create a config plugin:

diff --git a/app.plugin.js b/app.plugin.js
new file mode 100644
index 0000000..2a27230
--- /dev/null
+++ b/app.plugin.js
@@ -0,0 +1,8 @@
+const { withInfoPlist } = require("@expo/config-plugins");
+
+module.exports = (config, id) => {
+  return withInfoPlist(config, (config) => {
+    console.log(">>>", config);
+    return config;
+  });
+};

We then need to add it to the example app's config:

diff --git a/example/app.json b/example/app.json
index ef69fa7..ee74be2 100644
--- a/example/app.json
+++ b/example/app.json
@@ -13,6 +13,7 @@
       "presentationStyle": "modal"
     }
   ],
+  "plugins": ["react-native-test-app"],
   "resources": {
     "android": [
       "dist/res",

…and add @expo/config-plugins as a dependency:

diff --git a/example/package.json b/example/package.json
index 790926a..79fffae 100644
--- a/example/package.json
+++ b/example/package.json
@@ -24,6 +24,7 @@
   },
   "devDependencies": {
     "@babel/core": "^7.0.0",
+    "@expo/config-plugins": "^5.0.0",
     "@types/jest": "^27.0.0",
     "jest": "^27.0.0",
     "metro-react-native-babel-preset": "^0.67.0",

Finally, run:

yarn
cd example
pod install --project-directory=ios

…and verify that the content of Info.plist was output, and that tabs were converted to spaces (because @expo/config-plugins wrote to it).

tido64 avatar Aug 02 '22 22:08 tido64