react-native-menu / menu

UIMenu Component for React Native
MIT License
1.01k stars 62 forks source link

Build fails for iOS on react-native@0.74.1 with newArchEnabled and useFrameworks = static #801

Closed Kasendwa closed 4 months ago

Kasendwa commented 6 months ago

Hi! First of all, thanks for the wonderful work on this package.

I have failed to make a build with react-native@0.74.1, newArchEnabled = true and useFrameworks = "static"

The error is as shown below

Compiling @react-native-menu/menu Pods/react-native-menu » MenuViewManager.mm
› Compiling @react-native-menu/menu Pods/react-native-menu » MenuView.mm

❌  (node_modules/@react-native-menu/menu/ios/NewArch/MenuView.mm:2:9)

  1 | #ifdef RCT_NEW_ARCH_ENABLED
> 2 | #import <react_native_menu-Swift.h>
    |         ^ 'react_native_menu-Swift.h' file not found
  3 | #import "MenuView.h"
  4 | 
  5 | #import <react/renderer/components/RNMenuViewSpec/ComponentDescriptors.h>

› Preparing react-native Pods/React-RCTImage » React-RCTImage-Info.plist

I am using @react-native-menu/menu@1.0.2

Darren120 commented 6 months ago

solve?

Kasendwa commented 6 months ago

solve?

Sorry, did I do something wrong? Or missed out something?

Darren120 commented 6 months ago

solve?

Sorry, did I do something wrong? Or missed out something?

no i ask if u solve it

Kasendwa commented 6 months ago

it

Oh. Not yet. But hopefully I will find a solution soon.

I will update here in case of anything

rranjan14 commented 6 months ago

This patch solves it for me

index 6018cd1..23ef306 100644
--- a/node_modules/@react-native-menu/menu/ios/NewArch/MenuView.mm
+++ b/node_modules/@react-native-menu/menu/ios/NewArch/MenuView.mm
@@ -1,5 +1,5 @@
 #ifdef RCT_NEW_ARCH_ENABLED
-#import <react_native_menu-Swift.h>
+#import <react_native_menu/react_native_menu-Swift.h>
 #import "MenuView.h"

 #import <react/renderer/components/RNMenuViewSpec/ComponentDescriptors.h>
francosion042 commented 6 months ago

@rranjan14 what verson of react-native-menu do you have?

rranjan14 commented 6 months ago

@rranjan14 what verson of react-native-menu do you have?

1.0.2

francosion042 commented 6 months ago

@rranjan14 what verson of react-native-menu do you have?

1.0.2

hmm, i've tried and it didn't work for me

Kasendwa commented 6 months ago

This patch solves it for me

index 6018cd1..23ef306 100644
--- a/node_modules/@react-native-menu/menu/ios/NewArch/MenuView.mm
+++ b/node_modules/@react-native-menu/menu/ios/NewArch/MenuView.mm
@@ -1,5 +1,5 @@
 #ifdef RCT_NEW_ARCH_ENABLED
-#import <react_native_menu-Swift.h>
+#import <react_native_menu/react_native_menu-Swift.h>
 #import "MenuView.h"

 #import <react/renderer/components/RNMenuViewSpec/ComponentDescriptors.h>

Lovely! This worked for me. Thanks a lot.

JuanRdBO commented 6 months ago

Can we please merge this to main? I'd love to import this library

JuanRdBO commented 6 months ago

I'm getting this error:

Screenshot 2024-05-11 at 13 55 15
Kasendwa commented 6 months ago

I'm getting this error:

Screenshot 2024-05-11 at 13 55 15

I noticed this is with v1.0.3. The patch above should solves this. Do you know how to patch a package, may be?

MaxAst commented 6 months ago

@rranjan14's patch works for me, thank you! Would be great to get this fixed in @react-native-menu/menu

NiharR27 commented 6 months ago

+1 getting those too with "react-native":"0.74.1" and current latest version of the package "@react-native-menu/menu": "^1.1.0",. Will try and see if the patch works 🤞🏽

EDIT:

Works wIth the below patch (copied from other's suggestion above) 🥳 :

diff --git a/ios/MenuViewManager.mm b/ios/MenuViewManager.mm
index a9748300d787222d672b9f9dae33c7d04fd9f791..df4050034ee70b6560a81fbfb1fd4bc47155a9fa 100644
--- a/ios/MenuViewManager.mm
+++ b/ios/MenuViewManager.mm
@@ -7,7 +7,7 @@
 #import "MenuView.h"
 #else
 // OLD ARCH
-#import <react_native_menu-Swift.h>
+#import <react_native_menu/react_native_menu-Swift.h>
 #endif

 @interface MenuViewManager : RCTViewManager
diff --git a/ios/NewArch/MenuView.mm b/ios/NewArch/MenuView.mm
index 6018cd109bf156fcbd20ac455fb722546d50396c..23ef3067319738f998fb849b8673a58bb10df0b9 100644
--- a/ios/NewArch/MenuView.mm
+++ b/ios/NewArch/MenuView.mm
@@ -1,5 +1,5 @@
 #ifdef RCT_NEW_ARCH_ENABLED
-#import <react_native_menu-Swift.h>
+#import <react_native_menu/react_native_menu-Swift.h>
 #import "MenuView.h"

 #import <react/renderer/components/RNMenuViewSpec/ComponentDescriptors.h>
JuanRdBO commented 4 months ago

Now it works for me on the old arch, but new arch fails with the same error

Screenshot 2024-07-09 at 09 14 55
NadimRadjab commented 4 months ago

Bumping react-native-menu to 1.1.2 solved the issue for me.