From 80f82ff873c09d1b86e6f6fe5862da3150ded2c2 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:12:06 -0600 Subject: [PATCH 1/7] Update `OneSignalPluginProps` Motivation: * we aren't using iOSBundleIdentifier at all * add `iPhoneDeploymentTarget` to add ability to configure the target via plugin props --- onesignal/withOneSignal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onesignal/withOneSignal.ts b/onesignal/withOneSignal.ts index d4fdfa8..5be2cfa 100644 --- a/onesignal/withOneSignal.ts +++ b/onesignal/withOneSignal.ts @@ -12,8 +12,8 @@ export type OneSignalPluginProps = { * (iOS only) Environment name and bundle identifier */ mode: string; - iOsBundleIdentifier: string; devTeam: string; + iPhoneDeploymentTarget: string; }; const withOneSignal: ConfigPlugin = (config, props) => { From b20203b67fe79ce6e472727405a99eb618563b1c Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:15:20 -0600 Subject: [PATCH 2/7] Define and use `PluginOptions` interface Motivation: instead of continuing to pass in more and more arguments into the `xcodeProjectAddNSE` function. We can package them instead into `PluginOptions` and pass it as a single arg. --- onesignal/withOneSignalIos.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/onesignal/withOneSignalIos.ts b/onesignal/withOneSignalIos.ts index 7b06342..3ad83b9 100644 --- a/onesignal/withOneSignalIos.ts +++ b/onesignal/withOneSignalIos.ts @@ -16,6 +16,14 @@ import { IPHONEOS_DEPLOYMENT_TARGET, TARGETED_DEVICE_FAMILY } from "../support/i import { updatePodfile } from "../support/updatePodfile"; import { updateNSEEntitlements } from "../support/updateNSEEntitlements"; +/* I N T E R F A C E S */ +interface PluginOptions { + iosPath: string, + devTeam?: string, + bundleIdentifier?: string, + iPhoneDeploymentTarget?: string +} + // ---------- ---------- ---------- ---------- /** @@ -83,11 +91,16 @@ const withAppGroupPermissions: ConfigPlugin = ( const withOneSignalNSE: ConfigPlugin = (config, onesignalProps) => { return withXcodeProject(config, async props => { + const options: PluginOptions = { + iosPath: props.modRequest.platformProjectRoot, + bundleIdentifier: props.ios?.bundleIdentifier, + devTeam: onesignalProps?.devTeam, + iPhoneDeploymentTarget: onesignalProps?.iPhoneDeploymentTarget + }; + xcodeProjectAddNse( props.modRequest.projectName || "", - props.modRequest.platformProjectRoot, - props.ios?.bundleIdentifier || "", - onesignalProps?.devTeam, + options, "node_modules/onesignal-expo-plugin/build/support/serviceExtensionFiles/" ); @@ -110,11 +123,11 @@ export const withOneSignalIos: ConfigPlugin = ( export function xcodeProjectAddNse( appName: string, - iosPath: string, - bundleIdentifier: string, - devTeam: string | undefined, + options: PluginOptions, sourceDir: string ): void { + const { iosPath, devTeam, bundleIdentifier, iPhoneDeploymentTarget } = options; + updatePodfile(iosPath); updateNSEEntitlements(`group.${bundleIdentifier}.onesignal`) From 07f23114b03241efed9abcbb9bc5ab72dccf7ae2 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:18:07 -0600 Subject: [PATCH 3/7] Update NSE target code to use custom iPhoneDeploymentTarget Motivation: we set the NSE target `IPHONEOS_DEPLOYMENT_TARGET` value to the value passed in via plugin props. If undefined, we fallback via `??` to the default `IPHONEOS_DEPLOYMENT_TARGET`. --- onesignal/withOneSignalIos.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onesignal/withOneSignalIos.ts b/onesignal/withOneSignalIos.ts index 3ad83b9..051c1e7 100644 --- a/onesignal/withOneSignalIos.ts +++ b/onesignal/withOneSignalIos.ts @@ -219,7 +219,7 @@ export function xcodeProjectAddNse( ) { let buildSettingsObj = configurations[key].buildSettings; buildSettingsObj.DEVELOPMENT_TEAM = devTeam; - buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = IPHONEOS_DEPLOYMENT_TARGET; + buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iPhoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET; buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY; buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${targetName}/${targetName}.entitlements`; buildSettingsObj.CODE_SIGN_STYLE = "Automatic"; From 6fa03dcffaa38085a578794de6328ab0a6159bf4 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:18:51 -0600 Subject: [PATCH 4/7] Change default `IPHONEOS_DEPLOYMENT_TARGET` to "11.0" --- support/iosConstants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/iosConstants.ts b/support/iosConstants.ts index c1b561e..c28f08c 100644 --- a/support/iosConstants.ts +++ b/support/iosConstants.ts @@ -1,4 +1,4 @@ -export const IPHONEOS_DEPLOYMENT_TARGET = "10.0"; +export const IPHONEOS_DEPLOYMENT_TARGET = "11.0"; export const TARGETED_DEVICE_FAMILY = `\"1,2\"`; export const NSE_PODFILE_SNIPPET = ` From 643baa942406f52c73139270f739fd5e3a278ccf Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 17:27:15 -0600 Subject: [PATCH 5/7] Update test file --- testRuniOS.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/testRuniOS.ts b/testRuniOS.ts index 91ef8c0..37c2498 100644 --- a/testRuniOS.ts +++ b/testRuniOS.ts @@ -11,10 +11,16 @@ import { xcodeProjectAddNse } from "./onesignal/withOneSignalIos"; // - If you forget your main target in your Podfile you will get the // "Please add the host targets for the embedded targets to the Podfile." error // even if your .xcodeproj is correct. + +const options = { + iosPath: '.', + bundleIdentifier: "com.onesignal.XcodeTestProj", + devTeam: "99SW8E36CT", + iPhoneDeploymentTarget: '12.0' +}; + xcodeProjectAddNse( - "XcodeTestProj", - ".", - "com.onesignal.XcodeTestProj", - "99SW8E36CT", + "XcodeTestProj", + options, "../../repos/onesignal-expo-plugin/support/serviceExtensionFiles/" -); +); From 4e5ab0a62cb65548deca81ca24acb22ca61b8e00 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:21:11 -0600 Subject: [PATCH 6/7] Update README Motivation: with 3 plugin "props" it's better to include in a table. * since "devTeam" is optional, it's better to not include it in the example. * Update the version icon to beta 9 --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 895fcf9..5760cd9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

Welcome to onesignal-expo-plugin 👋

- Version + Version Documentation @@ -47,7 +47,6 @@ Add the plugin to the [plugin array](https://docs.expo.dev/versions/latest/confi "onesignal-expo-plugin", { "mode": "development", - "devTeam": "91SW8A37CR" } ] ] @@ -64,19 +63,21 @@ export default { [ "onesignal-expo-plugin", { - mode: process.env.NODE_ENV || "development", - devTeam: "91SW8A37CR" + mode: "development", } ] ] }; ``` -#### Plugin Options -* `mode`: used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. - - `"development"` - - `"production"` -* `devTeam`: *optional* - used to configure Apple Team ID. You can find your Apple Team ID by running `expo credentials:manager`. +#### Plugin Prop +You can pass props to the plugin config object to configure: + +| Plugin Prop | | | +|--------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` | +| `devTeam` | optional | Used to configure Apple Team ID. You can find your Apple Team ID by running `expo credentials:manager` e.g: `"91SW8A37CR"` | +| `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. | ### OneSignal App ID Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/): From 0af72812c89c70189a17c828aabe86ecc381ad09 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Fri, 7 Jan 2022 16:21:22 -0600 Subject: [PATCH 7/7] 1.0.0-beta9 Release Commit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8fa9807..dce39ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "onesignal-expo-plugin", - "version": "1.0.0-beta8", + "version": "1.0.0-beta9", "description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.", "main": "./app.plugin.js", "scripts": {