MaxAst / expo-share-extension

Expo config plugin for creating iOS share extensions with a custom view.
MIT License
190 stars 4 forks source link

Support new React Native architecture #42

Open chris-sark opened 1 month ago

chris-sark commented 1 month ago

Hello,

I am having a very similar issue to this one. The extension is hanging in the exact same way as the video in that issue, and I am unsure why. I have excluded expo-updates as well as most other expo packages I don't need, and for some reason I'm still getting crashes.

related files:

app.json

"plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          }
        }
      ],
      "expo-router",
      [
        "expo-secure-store",
        {
          "faceIDPermission": "Allow $(PRODUCT_NAME) to access your Face ID biometric data."
        }
      ],
      "expo-font",
     [ "expo-share-extension",
      {
        "excludedPackages": [
          "expo-build-properties",
          "expo-clipboard",
          "expo-constants",
          "expo-contacts",
          "expo-dev-client",
          "expo-device",
          "expo-font",
          "expo-image-picker",
          "expo-image",
          "expo-insights",
          "expo-linking",
          "expo-mail-composer",
          "expo-notifications",
          "expo-secure-store",
          "expo-sms",
          "expo-splash-screen",
          "expo-status-bar",
          "expo-updates",
          "expo-web-browser"
        ],
        "backgroundColor": {
          "red": 255,
          "green": 255,
          "blue": 255,
          "alpha": 0.8
        },
        "height": 500
      }
     ]
    ],

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ['react-native-reanimated/plugin'],
  };
};

package.json

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "@expo-google-fonts/inter": "^0.2.3",
    "@faker-js/faker": "^8.4.1",
    "@gorhom/bottom-sheet": "^4.6.4",
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-masked-view/masked-view": "^0.3.1",
    "@react-native-menu/menu": "^1.1.0",
    "@react-navigation/native": "^6.1.17",
    "@types/react": "~18.2.79",
    "axios": "^1.7.2",
    "expo": "~51.0.24",
    "expo-av": "~14.0.6",
    "expo-build-properties": "~0.12.4",
    "expo-clipboard": "~6.0.3",
    "expo-constants": "~16.0.2",
    "expo-contacts": "~13.0.5",
    "expo-dev-client": "~4.0.21",
    "expo-device": "~6.0.2",
    "expo-file-system": "~17.0.1",
    "expo-font": "~12.0.5",
    "expo-image": "~1.12.13",
    "expo-image-picker": "~15.0.7",
    "expo-insights": "~0.7.0",
    "expo-linear-gradient": "~13.0.2",
    "expo-linking": "~6.3.1",
    "expo-mail-composer": "~13.0.1",
    "expo-notifications": "~0.28.14",
    "expo-router": "~3.5.20",
    "expo-secure-store": "~13.0.2",
    "expo-share-extension": "^1.10.2",
    "expo-sms": "^12.0.1",
    "expo-splash-screen": "~0.27.5",
    "expo-status-bar": "~1.12.1",
    "expo-updates": "~0.25.21",
    "expo-web-browser": "~13.0.3",
    "libphonenumber-js": "^1.11.2",
    "lodash": "^4.17.21",
    "patch-package": "^8.0.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "^0.74.3",
    "react-native-element-dropdown": "^2.12.0",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-gradients": "^2.1.1",
    "react-native-indicators": "^0.17.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-pager-view": "6.3.0",
    "react-native-progress-wheel": "^2.1.0",
    "react-native-reanimated": "^3.10.1",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-native-share": "^10.2.1",
    "react-native-svg": "15.2.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-tab-view": "^3.5.2",
    "react-native-toast-message": "^2.2.0",
    "react-native-uuid": "^2.0.2",
    "react-native-view-shot": "^3.8.0",
    "react-native-web": "~0.19.10",
    "react-native-web-refresh-control": "^1.1.2",
    "react-redux": "^9.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "name": "app",
  "version": "1.0.0",
  "private": true,
  "main": "index.js",
}

All other files are the same as in the previously mentioned issue. the only other difference is that I am using eas build instead of prebuild. I did try running prebuild to see if there was maybe a problem with using eas build, but it still crashes. Let me know what I might be missing. Thanks!

chris-sark commented 2 weeks ago

@MaxAst Still running into this issue and I'm totally unsure why. When I run it through the xcode debugger by attaching a debugger to the process, these are the logs I get:

🟢 Registering module 'ExpoAsset'
🟢 Registering module 'ExpoVideoView'
🟢 Registering module 'EASClient'
🟢 Registering module 'ExponentFileSystem'
🟢 Registering module 'ExpoHaptics'
🟢 Registering module 'ExpoKeepAwake'
🟢 Registering module 'ExpoLinearGradient'
🟢 Registering module 'ExpoHead'
🟢 Registering module 'ExpoShareExtension'
🟢 Registering module 'ExpoDevLauncherInternal'
🟢 Registering module 'ExpoDevLauncherAuth'
🟢 Registering module 'RNCSafeAreaProvider'
🟢 Registering module 'ExpoDevMenu'
🟢 Registering module 'ExpoDevMenuInternal'
🟢 Registering module 'DevMenuPreferences'
🟢 Registering module 'RNCSafeAreaProvider'
AddInstanceForFactory: No factory registered for id <CFUUID 0x11051aca0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
-[_EXSinkLoadOperator loadItemForTypeIdentifier:completionHandler:expectedValueClass:options:] nil expectedValueClass allowing {(
    _EXItemProviderSandboxedResource,
    NSData,
    NSNumber,
    NSDictionary,
    NSError,
    NSArray,
    NSUUID,
    NSString,
    NSDate,
    CKShare,
    UIImage,
    DDRemoteActionContext,
    NSValue,
    NSURL
)}
Running application shareExtension ({
    initialProps =     {
        url = "https://www.apple.com/";
    };
    rootTag = 1;
})
Unbalanced calls start/end for tag 19

And then the process just aborts. Would love some more insight here if you have any, thanks!

Attached is an img with data re memory useage, etc. Screenshot 2024-08-26 at 9 35 10 PM

chris-sark commented 2 weeks ago

@MaxAst As a third follow up - I tried to get the share extension working with a minimum reproducible example, but I'm still running into the same issue. Here is the repo for the example - all the files are there. I essentially just ran npx create-expo-app@latest and then followed the install instructions for expo share extension. To run, npm install -> npx expo prebuild -p ios --clean -> npx expo run:ios should do the trick.

Please let me know if you can help out here, thanks!

chris-sark commented 2 weeks ago

@MaxAst Okay! I finally figured out what was causing the issue: it's because I'm using the new react native architecture through expo's expo-build-properties. In my plugins, I have the following:

      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          }
        }
      ],

and when I remove it, there's no crash!

Going to update this card to detail 'support new architecture'.

Thx again for the lib, going to be using this all the time

MaxAst commented 2 weeks ago

ohh interesting, thanks for reporting @chris-sark! I'll make sure that the new architecture is supported going forward. Sorry for getting back to you late, I haven't had much time for expo-share-extension over the past month

chris-sark commented 2 weeks ago

No worries! I'll likely be around a lot posting bugs / requests, looking forward to collaborating!

While I have you - what's the best way to share data between the extension and the main app via async storage? I need to make an api call in the share extension which requires a token stored in async storage under the main app.

Thanks again!

MaxAst commented 2 weeks ago

For that I use react-native-mmkv

AkbarKhamid commented 1 week ago

@MaxAst Hi, may I ask how you are using mmkv without the new arch enabled? mmkv supports app groups from the version 3 and up which requires the new arch. I had a similar use case so I upgraded to new arch, unfortunately now this package is crashing...

chris-sark commented 1 week ago

@AkbarKhamid I ended up using react-native-shared-group-preferences, although I imagine you could just download an older version of mmkv (v2.x.x) as that does not require new arch

AkbarKhamid commented 1 week ago

I do not think app groups are supported by mmkv in versions below 3.x (per the release notes). I will try to setup react-native-shared-group-preferences then.