Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
singh-sukhmanjit opened this issue Jan 8, 2024 · 20 comments

Comments

@singh-sukhmanjit
Copy link

singh-sukhmanjit commented Jan 8, 2024

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
Copy link

lindboe commented Jan 18, 2024

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
Copy link

mhsfh commented Jan 20, 2024

Hi @lindboe ,
what is the latest react-native version compatible with the [email protected]?
is it [email protected] as shown in the example?
thanks

@lindboe
Copy link

lindboe commented Jan 22, 2024

@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: #294

@mhsfh
Copy link

mhsfh commented Jan 22, 2024

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

@EKOzkan
Copy link

EKOzkan commented Jan 27, 2024

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

Can you describe the path you fallowed?

@mhsfh
Copy link

mhsfh commented Jan 27, 2024

@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
Copy link

EKOzkan commented Jan 27, 2024

@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
Copy link
Author

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

@RobledoFootbao
Copy link

@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
Copy link

image

@jorgegvallejo
Copy link

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
Copy link

Found Pull Request #260 witch fixes this issue:

image

@jorgegvallejo
Copy link

Found Pull Request #260 witch fixes this issue:

image

So it works for you with the new arch enabled?

@Karthik-B-06
Copy link

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

@VikalpP
Copy link

VikalpP commented May 10, 2024

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
             }
 
-            resolve([DATA_KEY: data])
+            var intent: INSendMessageIntent? = nil
+            var conversationIdentifier: String? = nil
+
+            // Populate the recipient property with the metadata in case the user taps a suggestion from the share sheet.
+            if #available(iOS 13.0, *) {
+                intent = extensionContext.intent as? INSendMessageIntent
+            } else {
+                intent = nil
+            }
+            if intent != nil {
+                conversationIdentifier = intent!.conversationIdentifier
+            }
+
+            resolve([DATA_KEY: data ?? nil, CONVERSATION_IDENTIFIER_KEY: conversationIdentifier ?? nil])
         }
     }
 
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()?
-      .jsBundleURL(forBundleRoot: "index.share", fallbackResource: nil)
+      .jsBundleURL(forBundleRoot: "index.share")
 #else
     return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
 #endif
@@ -52,6 +52,7 @@ class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactSha
   override func viewDidDisappear(_ animated: Bool) {
     cancel()
     ShareMenuReactView.detachViewDelegate()
+    super.viewDidDisappear(animated)
   }
 
   func loadExtensionContext() -> NSExtensionContext {
  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
-                            let text:String! = item as? String
+                            let text: String! = item as? String
 
                             results.append([DATA_KEY: text, MIME_TYPE_KEY: "text/plain"])
 

@jorgegvallejo
Copy link

@lindboe hey, are you all still supporting this lib?

@lindboe
Copy link

lindboe commented Sep 17, 2024

Hi @jorgegvallejo, my team at Infinite Red is no longer working on this project and I'm personally not sure of future plans for it. Any questions about this repository will need to be directed to Expensify.

If you have questions on the Infinite Red team's prior work and want to talk with us directly, you can reach us via our website form or our community slack.

@HugoGresse
Copy link

I had some issues with RN 0.74, so this patch solve them
react-native-share-menu+6.0.0.patch

@jliukai
Copy link

jliukai commented Oct 7, 2024

im still having trouble building ios
xcode 16,
iOS 18.
"react-native": "0.72.5",
iOS deployment target 15.5.

I applied @HugoGresse patch.
I ran pod install

then react-native run-ios failed

The following build commands failed:
	PhaseScriptExecution [CP]\ Copy\ Pods\ Resources 
	/Users/xxxxxx/Library/Developer/Xcode/DerivedData/mobile-aa..../Build/Intermediates.noindex/mobile.build/Debug-iphoneos/ShareExtension.build/Script-C...9.sh 
	(in target 'ShareExtension' from project 'mobile')
	Building workspace mobile with scheme mobile and configuration Debug
(2 failures)

any ideas?
ive purged pod/ podfile.lock, xcode clean build, ... still get the above error.

Other clarification questions

  • xcode > create target "share extension",
    -asks if i want to activate for debug. i said yes.
    - create a objective C bridge.? i said yes.

@HugoGresse
Copy link

I had no issue with RN 0.72 and 0.73 with the current share-menu version.
Only this patch much smaller patch:
react-native-share-menu+6.0.0.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests