zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 747 forks source link

Update import format to XCode 14.2 compat #821

Open NaeemCheema opened 1 year ago

NaeemCheema commented 1 year ago

:beetle: Description

The import #import "RCTUtils.h" in /RNSound/RNSound.m is causing issues in XCode 14.2. It looks like the same issue as this expo issue: https://github.com/expo/expo/issues/15622#issuecomment-997141629

For us, the expo workaround https://github.com/expo/expo/pull/15655 with expo_patch_react_imports isn't consistently working, so it would be great to change the import into #import <React/RCTUtils.h>.

Is that an option? Would you accept a PR for that?

:beetle: What is the observed behavior?

:beetle: What is the expected behavior?

:beetle: Please post your code:

This patch works for us:
diff --git a/node_modules/react-native-sound/RNSound/RNSound.m b/node_modules/react-native-sound/RNSound/RNSound.m
index df3784e..17e5894 100644
--- a/node_modules/react-native-sound/RNSound/RNSound.m
+++ b/node_modules/react-native-sound/RNSound/RNSound.m
@@ -1,10 +1,5 @@
 #import "RNSound.h"
-
-#if __has_include("RCTUtils.h")
-#import "RCTUtils.h"
-#else
 #import <React/RCTUtils.h>
-#endif

 @implementation RNSound {
     NSMutableDictionary *_playerPool;

:bulb: Does the problem have a test case?

:bulb: **Possible solution**

:bulb: Is there a workaround?

:bulb: If the bug is confirmed, would you be willing to create a pull request?

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

If your problem is happening on a device, which device?