about summary refs log tree commit diff
path: root/plugins/notificationsExtension/withExtensionViewController.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/notificationsExtension/withExtensionViewController.js')
-rw-r--r--plugins/notificationsExtension/withExtensionViewController.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/notificationsExtension/withExtensionViewController.js b/plugins/notificationsExtension/withExtensionViewController.js
new file mode 100644
index 000000000..cd29bea7d
--- /dev/null
+++ b/plugins/notificationsExtension/withExtensionViewController.js
@@ -0,0 +1,31 @@
+const {withXcodeProject} = require('@expo/config-plugins')
+const path = require('path')
+const fs = require('fs')
+
+const withExtensionViewController = (
+  config,
+  {controllerName, extensionName},
+) => {
+  // eslint-disable-next-line no-shadow
+  return withXcodeProject(config, config => {
+    const controllerPath = path.join(
+      config.modRequest.projectRoot,
+      'modules',
+      extensionName,
+      `${controllerName}.swift`,
+    )
+
+    const targetPath = path.join(
+      config.modRequest.platformProjectRoot,
+      extensionName,
+      `${controllerName}.swift`,
+    )
+
+    fs.mkdirSync(path.dirname(targetPath), {recursive: true})
+    fs.copyFileSync(controllerPath, targetPath)
+
+    return config
+  })
+}
+
+module.exports = {withExtensionViewController}