exponea / exponea-react-native-sdk

MIT License
8 stars 13 forks source link

Exponea.m - Declaration of 'RCTEventEmitter' must be imported from module 'React.RCTEventEmitter' before it is required #82

Closed petgus-lyko closed 1 year ago

petgus-lyko commented 1 year ago

Upgraded from v.1.2.0 -> v.1.3.1

There's seems to be a newly added conditional import that is causing an error when I build my Xcode project.

Declaration of 'RCTEventEmitter' must be imported from module 'React.RCTEventEmitter' before it is required

Screenshot 2023-03-20 at 10 31 03

Using Xcode 14.1 React Native 0.70.6

Have tried cleaning build folder and also tried rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install;

Any advice on how to solve this?

adam1929 commented 1 year ago

Hi @petgus-lyko thank you for your report. That conditional-import has been provided due to 'our' issue that XCode wasn't able to locate RCTEventEmitter. So it seems as environment setup/difference. I found similar problem with solution:

# Workaround build error for classic quoted imports
installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    unless ['React-Core', 'React-RCTText'].include? target.name
      config.build_settings["USE_HEADERMAP"] = "NO"
    end
  end
end

from here: https://github.com/expo/expo/issues/15622 But we'll look at it also. We have no report from other clients :-/ it may be hard to find a solution.

petgus-lyko commented 1 year ago

Thank you for reply @adam1929. I tried the fix and ended up with another import error. Seems the problem now is that a supporting file in Exponea SDK can't be found.

The file that can't be found. https://github.com/exponea/exponea-ios-sdk/blob/2.5.0/ExponeaSDK/ExponeaSDK/Supporting%20Files/objc_tryCatch.h

The error

Screenshot 2023-04-06 at 18 51 02
petgus-lyko commented 1 year ago

Resorted to using patch-package, removing the conditional import statement from Exponea.m

diff --git a/node_modules/react-native-exponea-sdk/ios/Exponea.m b/node_modules/react-native-exponea-sdk/ios/Exponea.m
index fcbf6d4..bb24474 100644
--- a/node_modules/react-native-exponea-sdk/ios/Exponea.m
+++ b/node_modules/react-native-exponea-sdk/ios/Exponea.m
@@ -1,9 +1,5 @@
 #import <React/RCTBridgeModule.h>
-#if __has_include("RCTEventEmitter.h")
-#import "RCTEventEmitter.h"
-#else
 #import <React/RCTEventEmitter.h>
-#endif
adam1929 commented 1 year ago

Hi @petgus-lyko you opened issue again, it is still related to your last finding? We already create a new release, can you reproduce your issue? Unfortunately, we have no such experience with Exponea.m file. That change was created because of new RN usage, maybe you are using older RN than 70.6 that is not compatible with that change? Or you have 'Parallel builds' enabled in Xcode? For missing objc_tryCatch.h file, try to check our Podfile in example app. Also please check Enable Bitcode in Build Options in XCode. It somehow reminds me that build conf :-/