customerio / customerio-expo-plugin

MIT License
11 stars 9 forks source link

CioTracking has a minimum deployment target of iOS 13.4 / Expo 50 #122

Closed joeyhotz closed 9 months ago

joeyhotz commented 10 months ago

The Expo 50 upgrade raises the minimum deployment target for iOS to 13.4. When building for iOS on Expo 50, I get this error:

❌  (ios/NotificationService/NotificationService.swift:3:8)

  1 | import Foundation
  2 | import UserNotifications
> 3 | import CioTracking
    |        ^ compiling for iOS 13.0, but module 'CioTracking' has a minimum deployment target of iOS 13.4: /Users/joey.hotz/Library/Developer/Xcode/DerivedData/JuniperDev-hacfncojyukwnjbogrjrlcqfrlrn/Build/Products/Debug-iphonesimulator/CustomerIOTracking/CioTracking.swiftmodule/arm64-apple-ios-simulator.swiftmodule
  4 | import CioMessagingPushAPN
  5 | 
  6 | @objc
    "expo": "^50.0.0-preview.11",
    "react-native": "0.73.2",
    "customerio-expo-plugin": "^1.0.0-beta.13",
    "customerio-reactnative": "^3.3.2",

There appears to be some sort of version mismatch with CIO dependencies. Does anyone have any more insight for a potential fix?

mrehan27 commented 10 months ago

Thank you for reaching us and highlighting this issue. Unfortunately, we haven't tested the plugin with Expo 50 as of yet. Can you please confirm whether you're using the bare or managed workflow? If it's the bare workflow, have you tried raising the minimum deployment target for pod giving the error to 13.4 using XCode Build Settings?

Do let us know if this works for you. If you need further assistance, please don't hesitate to reach out.

joeyhotz commented 10 months ago

Hey @mrehan27, we are using the managed workflow. I've tried setting the ios deployment target to 13.4 with the expo-build-properties plugin but I'm still seeing the above error. It seems that in some of the CIO packages the deployment target is hardcoded at 13.0

mrehan27 commented 10 months ago

Thank you for the confirmation @joeyhotz. I've tried to reproduce the issue using a new app with Expo 50 but have not been successful. The plugin seems to work fine in a newly created app with Expo 50. Can you provide more details on what might have been done differently in your app? Or if you could share a simple sample app that reproduces this issue, it would help a lot. This way, we can reproduce the problem on our end to investigate further, and help you better. Appreciate your cooperation!

MaxAst commented 10 months ago

looks like this needs to be updated to 13.4

levibostian commented 10 months ago

Thanks for the suggestion, @MaxAst.

We have continued internally to reproduce issues with the Customer.io Expo plugin and Expo 50. Unfortunately, we continue to not encounter compilation errors.

If someone is able to provide more information or reproduce the error in a sample app, we would be able to move forward to providing a fix for everyone.

darnfish commented 10 months ago

Following from the last issue, I'm running into The plist file at path NotificationService-Info.plist doesn't exist after upgrading to Expo 50. The git patch here also did not work for me.

levibostian commented 10 months ago

@darnfish, that error message is probably related to a Notification Service Extension target added to your Xcode project for the iOS app.

Could you try expo prebuild --clean to re-generate your Xcode project and re-create this target?

giaset commented 10 months ago

Running expo prebuild --clean changes nothing on my end. Same error:

⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: An error occurred while processing the post-install hook of the Podfile.

[!] The plist file at path `/Users/giaset/Desktop/Projects/hotstreak-rn-web/ios/NotificationService-Info.plist` doesn't exist.

/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/plist.rb:17:in `read_from_path'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/node_modules/react-native/scripts/cocoapods/utils.rb:553:in `block in update_ats_in_plist'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `each'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `update_ats_in_plist'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/node_modules/react-native/scripts/cocoapods/utils.rb:575:in `apply_ats_config'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/node_modules/react-native/scripts/react_native_pods.rb:310:in `react_native_post_install'
/Users/giaset/Desktop/Projects/hotstreak-rn-web/ios/Podfile:63:in `block (3 levels) in from_ruby'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-core-1.12.1/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:307:in `generate_pods_project'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:183:in `integrate'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:170:in `install!'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>'

pod install --repo-update --ansi exited with non-zero code: 1
ami-aman commented 10 months ago

Hi @joeyhotz

I'm filling in for Levi. I apologize for the difficulties you're experiencing with upgrading to Expo SDK 50. Please note that we do not currently support Expo SDK 50, but it is on our roadmap in the future. In the meantime, we recommend using Expo SDK version 49 or earlier.

giaset commented 10 months ago

No worries. We absolutely need support for Expo 50 for compatibility with other libraries we use, so we will look at migrating off customer.io as a next step

ami-aman commented 10 months ago

@giaset and the team here, I hope my reply didn't feel dismissive. We've been researching as a team and so far confirmed that there are two issues with Expo SDK 50 upgrade and they are:

(Both the issues have been reported in the threads above.)

For the issue #1 i.e. ios.deploymentTarget needs to be at least version 13.4 where as our iOS SDK's minimum deployment target is 13.0. The quick fix to this would be to set the following property to 13.4, but we don't recommend this yet because of issue #2.

[
            "expo-build-properties",
            {
                "ios": {
                    "deploymentTarget": "13.4"
                }
            }
]

2 issue: The plist file at path /Users/amandeepkaur/Documents/expo-all-test-apps/expo-test-app-50/ios/NotificationService-Info.plist doesn't exist. Our plugin creates this file in folder path NotificationService which has worked in prior versions.

Okay, then what happened?

Expo SDK 50 makes use of React native version 0.73.0. Expo also adds post_install to podfile that runs some code to ensure that the project is setup correctly. One such method that's called in post_install is get_plist_paths_from that fetches all the files that end with Info.plist in the project.

In our case , it fetches two files namely Info.plist and NotificationService-Info.plist and tries to locate these two files at path ./ios . One file (Info.plist) exists here but the other file NotificationService-Info.plist is not found hence throws the error.

How did we confirm this?

We copied the file NotificationService-Info.plist to ./ios path and again ran pod install explicitly, everything went pretty smooth and :tada: pod install was complete.

So what now?

This issue seems to be coming from react native > 0.73.0 version. An issue has been reproduced and raised with the RN repo and we're following it while continuing to explore ways around this.

Thank you and to this group for your patience and help with the investigation. We know it's a painful one and will be working to find an option while trying to avoid brute force hacks until we've exhausted all options. Let's keep the ideas and conversations going-- we're all ears here, too!

darnfish commented 10 months ago

Thank you so much for your help here :~) for the plist issue, do you know if you could provide a git patch that we could temporarily use with patch-package until this issue is fixed in an update?

DavidLichy commented 10 months ago

This includes fix for deployment target and plist

Copy to patches/customerio-expo-plugin+1.0.0-beta.13.patch at project root

diff --git a/node_modules/customerio-expo-plugin/lib/commonjs/helpers/constants/ios.js b/node_modules/customerio-expo-plugin/lib/commonjs/helpers/constants/ios.js
index 5426e1f..95c5420 100644
--- a/node_modules/customerio-expo-plugin/lib/commonjs/helpers/constants/ios.js
+++ b/node_modules/customerio-expo-plugin/lib/commonjs/helpers/constants/ios.js
@@ -18,7 +18,7 @@ exports.LOCAL_PATH_TO_CIO_NSE_FILES = LOCAL_PATH_TO_CIO_NSE_FILES;
 function getRelativePathToRNSDK(currentFile) {
   return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK);
 }
-const IOS_DEPLOYMENT_TARGET = '13.0';
+const IOS_DEPLOYMENT_TARGET = '13.4';
 exports.IOS_DEPLOYMENT_TARGET = IOS_DEPLOYMENT_TARGET;
 const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
 exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = GROUP_IDENTIFIER_TEMPLATE_REGEX;
diff --git a/node_modules/customerio-expo-plugin/lib/commonjs/ios/withNotificationsXcodeProject.js b/node_modules/customerio-expo-plugin/lib/commonjs/ios/withNotificationsXcodeProject.js
index 1c20031..2cb320b 100644
--- a/node_modules/customerio-expo-plugin/lib/commonjs/ios/withNotificationsXcodeProject.js
+++ b/node_modules/customerio-expo-plugin/lib/commonjs/ios/withNotificationsXcodeProject.js
@@ -108,13 +108,15 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
     const targetFile = getTargetFile(filename);
     _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
   });
-
+  const infoPlistTargetFileFix = `${iosPath}/${PLIST_FILENAME}`;
+  _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${PLIST_FILENAME}`, infoPlistTargetFileFix);
   /* MODIFY COPIED EXTENSION FILES */
   const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
   updateNseInfoPlist({
     bundleVersion,
     bundleShortVersion,
-    infoPlistTargetFile
+    infoPlistTargetFile,
+    infoPlistTargetFileFix
   });
   updateNseEnv(options, getTargetFile(ENV_FILENAME));

@@ -157,7 +159,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
     if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${_ios.CIO_NOTIFICATION_TARGET_NAME}"`) {
       const buildSettingsObj = configurations[key].buildSettings;
       buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
-      buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
+      buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.4';
       buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
       buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
       buildSettingsObj.SWIFT_VERSION = 4.2;
@@ -172,13 +174,17 @@ const updateNseInfoPlist = payload => {
   const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
   const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
   let plistFileString = _fileManagement.FileManagement.readFile(payload.infoPlistTargetFile);
+  let plistFileFixString = _fileManagement.FileManagement.readFile(payload.infoPlistTargetFileFix);
   if (payload.bundleVersion) {
     plistFileString = (0, _codeInjection.replaceCodeByRegex)(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
+    plistFileFixString = (0, _codeInjection.replaceCodeByRegex)(plistFileFixString, BUNDLE_VERSION_RE, payload.bundleVersion);
   }
   if (payload.bundleShortVersion) {
     plistFileString = (0, _codeInjection.replaceCodeByRegex)(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
+    plistFileFixString = (0, _codeInjection.replaceCodeByRegex)(plistFileFixString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
   }
   _fileManagement.FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
+  _fileManagement.FileManagement.writeFile(payload.infoPlistTargetFileFix, plistFileString);
 };
 const updateNseEnv = (options, envFileName) => {
   var _options$pushNotifica2, _options$pushNotifica4, _options$pushNotifica6;
diff --git a/node_modules/customerio-expo-plugin/lib/module/helpers/constants/ios.js b/node_modules/customerio-expo-plugin/lib/module/helpers/constants/ios.js
index 37e7393..4976cca 100644
--- a/node_modules/customerio-expo-plugin/lib/module/helpers/constants/ios.js
+++ b/node_modules/customerio-expo-plugin/lib/module/helpers/constants/ios.js
@@ -9,7 +9,7 @@ export const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'src/hel
 export function getRelativePathToRNSDK(currentFile) {
   return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK);
 }
-export const IOS_DEPLOYMENT_TARGET = '13.0';
+export const IOS_DEPLOYMENT_TARGET = '13.4';
 export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
 export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
 export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
diff --git a/node_modules/customerio-expo-plugin/lib/module/ios/withNotificationsXcodeProject.js b/node_modules/customerio-expo-plugin/lib/module/ios/withNotificationsXcodeProject.js
index 11452de..9e70398 100644
--- a/node_modules/customerio-expo-plugin/lib/module/ios/withNotificationsXcodeProject.js
+++ b/node_modules/customerio-expo-plugin/lib/module/ios/withNotificationsXcodeProject.js
@@ -150,7 +150,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
     if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
       const buildSettingsObj = configurations[key].buildSettings;
       buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
-      buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
+      buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.4';
       buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
       buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
       buildSettingsObj.SWIFT_VERSION = 4.2;
giaset commented 10 months ago

Thank you, appreciate the detailed write-up. We ended up writing a similar patch on our end rather than wait for a new release -- that's unblocked us for the time being!

joeyhotz commented 9 months ago

Thanks all! The patch worked for us :)

We also found a customerio-expo-plugin prop that lets you set the ios deployment target without having to patch the module for iOS 13.4. Perhaps worth adding to the plugins documentation.

 [
        '@eucalyptusvc/customerio-expo-plugin',
        {
          ...,
          ios: {
            ...,
            iosDeploymentTarget: '13.4',
          },
        },
      ],
ami-aman commented 9 months ago

I'm happy to share that React Native has released version 0.73.3, fixing the issue as mentioned in the above thread. However, this fix currently requires an update to the Expo SDK (PR already open) to integrate the new React Native version.

Rest assured, we're closely monitoring the Expo releases and actively checking for plugin compatibility with Expo SDK 50. We'll keep you updated every step of the way.

Thank you for your continued patience and understanding.

darnfish commented 9 months ago

This got merged: https://github.com/expo/expo/pull/26774#event-11722641843

AdamGerthel commented 9 months ago

I guess we're just waiting for Expo to publish a new version which includes the merged changes?

Update: I just realized that Expo@latest installs RN 0.73.4, but I'm still getting the error:

compiling for iOS 13.0, but module 'CioTracking' has a minimum deployment target of iOS 13.4

Update 2: Using the latest Expo 50 version with iosDeploymentTarget: '13.4' as mentioned above works!

ami-aman commented 9 months ago

I am here to update you that Expo has released version 50.0.6 which includes the fixed react native version. Making our plugin fully compatible with the latest Expo version is on our raodmap. We're actively working on an update and will release it soon. Thank you again for your patience and understanding! I'll keep you all informed about our progress on this.

Titouaks commented 9 months ago

following this thread

ami-aman commented 9 months ago

🎊 Great news! customerio-expo-plugin is now compatible with Expo SDK 50. 🎊

The long-awaited customerio-expo-plugin with Expo SDK 50 support is finally available and ready to use! Make sure you are using customerio-expo-plugin v1.0.0-beta.15 and Expo SDK v50.0.6 since it supports the react native fix.

Thanks to everyone for your patience and support while we worked on making this happen. To get started, follow our Expo docs here.

Now that our plugin is compatible with Expo SDK 50, I will go ahead and close this ticket. In case you encounter any issues, feel free to connect with us on win@customer.io.