Expensify / react-native-share-menu

A module for React Native that adds your app to the share menu of the device
MIT License
632 stars 235 forks source link

iOS app is not building with new architecture in react native 0.72.6 #302

Open singh-sukhmanjit opened 6 months ago

singh-sukhmanjit commented 6 months ago

React Native 0.72.6 Xcode 15 New architecture enabled

App builds successfully with old architecture but gives following error with new architecture while building -

image

Below is the podspec for Share Extension

target 'ShareExtension' do
  use_react_native!

  pod 'RNShareMenu', :path => '../node_modules/react-native-share-menu'
end
lindboe commented 6 months ago

Yeah, the project does not currently support the new architecture. If you'd like to follow along, we're tracking support for this in #293.

mhsfh commented 6 months ago

Hi @lindboe , what is the latest react-native version compatible with the react-native-share-menu@6.0.0? is it react-native@0.63.2 as shown in the example? thanks

lindboe commented 6 months ago

@mhsfh if you're not using the new architecture, which is not required by recent react native, you can use the latest version of react native with a few patches to this library (using patch-package). Check out the list in Phase 0 for the PRs that fix those issues, you can copy their fix as a patch for now: https://github.com/Expensify/react-native-share-menu/issues/294

mhsfh commented 6 months ago

@lindboe I made it work, thank you so much 🙏

EKOzkan commented 5 months ago

@lindboe I made it work, thank you so much 🙏

Can you describe the path you fallowed?

mhsfh commented 5 months ago

@lindboe I made it work, thank you so much 🙏

Can you describe the path you fallowed?

for android I had to apply this patch:

diff --git a/android/build.gradle b/android/build.gradle
index 9557fdbf2fbf97b7f7aeaf7ce86d301a8ced213d..8adad42908c0d73c535c30f01c5437e2a7d9f33f 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,7 +1,7 @@
 apply plugin: 'com.android.library'

 android {
-    compileSdkVersion 29
+    compileSdkVersion rootProject.ext.compileSdkVersion
     buildToolsVersion "29.0.2"

     defaultConfig {

are you facing ios errors?

EKOzkan commented 5 months ago

@lindboe I made it work, thank you so much 🙏

Can you describe the path you fallowed?

for android I had to apply this patch:

diff --git a/android/build.gradle b/android/build.gradle
index 9557fdbf2fbf97b7f7aeaf7ce86d301a8ced213d..8adad42908c0d73c535c30f01c5437e2a7d9f33f 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,7 +1,7 @@
 apply plugin: 'com.android.library'

 android {
-    compileSdkVersion 29
+    compileSdkVersion rootProject.ext.compileSdkVersion
     buildToolsVersion "29.0.2"

     defaultConfig {

are you facing ios errors?

Yeah, I've been trying to get this package to work on iOS for several days. I've experimented with different React Native versions, various projects, and different paths, but unfortunately, I haven't had any luck with it.

singh-sukhmanjit commented 5 months ago

@EKOzkan am using react-native-share-menu 6.0.0 with react-native 0.72.6. what issue are you facing?

RobledoFootbao commented 4 months ago

@EKOzkan am using react-native-share-menu 6.0.0 with react-native 0.72.6. what issue are you facing?

Hello @singh-sukhmanjit here to me I'm facing with "'RNShareMenu-Swift.h' file not found" message when I try build iOS.

React-Native 0.72 Xcode 15.3 Apple M3

It's happen in file "node_modules/react-native-share-menu/ios/ShareMenuManager.m" line 9: #import "RNShareMenu-Swift.h"

Where is this file?

RobledoFootbao commented 3 months ago
image
jorgegvallejo commented 3 months ago

I can't get it to build with the custom view config either.

RN 0.73.6

Screenshot 2024-03-28 at 3 09 05 PM

LukasB-DEV commented 2 months ago

Found Pull Request #260 witch fixes this issue:

image

jorgegvallejo commented 2 months ago

Found Pull Request #260 witch fixes this issue:

image

So it works for you with the new arch enabled?

Karthik-B-06 commented 2 months ago

Has someone made it work with Expo? I am using Expo Dev Client.

VikalpP commented 2 months ago

I'm running the App on iOS 17.4 with React native v0.73.6. Share Menu is working fine on my app. Here's the all patches that I have applied in case any one find it helpful -

  1. Patch 1

    
    diff --git a/node_modules/react-native-share-menu/ios/Constants.swift b/node_modules/react-native-share-menu/ios/Constants.swift
    index 08385b7..87b0d11 100644
    --- a/node_modules/react-native-share-menu/ios/Constants.swift
    +++ b/node_modules/react-native-share-menu/ios/Constants.swift
    @@ -42,6 +42,7 @@ public let COLOR_TRANSPARENT_KEY = "Transparent"
    
    public let MIME_TYPE_KEY =  "mimeType"
    public let DATA_KEY =  "data"
    +public let CONVERSATION_IDENTIFIER_KEY = "conversationIdentifier"
    public let EXTRA_DATA_KEY =  "extraData"
    
    // MARK: Events
    diff --git a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    index e290cce..24cd59b 100644
    --- a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    +++ b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    @@ -7,6 +7,7 @@
    
    import Foundation
    import MobileCoreServices
    +import Intents
    
    @objc(ShareMenuReactView)
    public class ShareMenuReactView: NSObject {
    @@ -45,6 +46,7 @@ public class ShareMenuReactView: NSObject {
         }
    
         extensionContext.completeRequest(returningItems: [], completionHandler: nil)
    +        ShareMenuReactView.detachViewDelegate()
     }
    
     @objc
    @@ -89,7 +91,20 @@ public class ShareMenuReactView: NSObject {
                 return
             }

diff --git a/node_modules/react-native-share-menu/ios/ReactShareViewController.swift b/node_modules/react-native-share-menu/ios/ReactShareViewController.swift index f42bce6..a827e7f 100644 --- a/node_modules/react-native-share-menu/ios/ReactShareViewController.swift +++ b/node_modules/react-native-share-menu/ios/ReactShareViewController.swift @@ -13,7 +13,7 @@ class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactSha func sourceURL(for bridge: RCTBridge!) -> URL! {

if DEBUG

 return RCTBundleURLProvider.sharedSettings()?
  1. Fix File Sharing

    
    diff --git a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    index 24cd59b..e1972cc 100644
    --- a/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    +++ b/node_modules/react-native-share-menu/ios/Modules/ShareMenuReactView.swift
    @@ -57,6 +57,7 @@ public class ShareMenuReactView: NSObject {
         }
    
         viewDelegate.openApp()
    +        ShareMenuReactView.detachViewDelegate()
     }
    
     @objc(continueInApp:)
    @@ -74,6 +75,7 @@ public class ShareMenuReactView: NSObject {
         }
    
         viewDelegate.continueInApp(with: items, and: extraData)
    +        ShareMenuReactView.detachViewDelegate()
     }
    
     @objc(data:reject:)
    @@ -121,7 +123,16 @@ public class ShareMenuReactView: NSObject {
                 }
    
                 for provider in attachments {
    -                    if provider.hasItemConformingToTypeIdentifier(kUTTypeURL as String) {
    +                    if provider.hasItemConformingToTypeIdentifier(kUTTypeFileURL as String) {
    +                        provider.loadItem(forTypeIdentifier: kUTTypeFileURL as String, options: nil) { (item, error) in
    +                            let url: URL! = item as? URL
    +
    +                            results.append([DATA_KEY: url.absoluteString, MIME_TYPE_KEY: self.extractMimeType(from: url)])
    +
    +                            semaphore.signal()
    +                        }
    +                        semaphore.wait()
    +                    } else if provider.hasItemConformingToTypeIdentifier(kUTTypeURL as String) {
                         provider.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil) { (item, error) in
                             let url: URL! = item as? URL

@@ -132,7 +143,7 @@ public class ShareMenuReactView: NSObject { semaphore.wait() } else if provider.hasItemConformingToTypeIdentifier(kUTTypeText as String) { provider.loadItem(forTypeIdentifier: kUTTypeText as String, options: nil) { (item, error) in