zmxv / react-native-sound

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

[iOS] Can't build with react-native 0.67.4 #786

Open aprilmintacpineda opened 2 years ago

aprilmintacpineda commented 2 years ago

:beetle: Description

I'm trying to build with react-native 0.67.4 bare react-app on iOS but it always fails with the following errors:

node_modules/react-native-sound/RNSound/RNSound.m:236:44: Implicit declaration of function 'RCTJSErrorFromNSError' is invalid in C99
node_modules/react-native-sound/RNSound/RNSound.m:236:44: Declaration of 'RCTJSErrorFromNSError' must be imported from module 'React.RCTUtils' before it is required
node_modules/react-native-sound/RNSound/RNSound.m:236:44: Conflicting types for 'RCTJSErrorFromNSError'

It works fine with android though.

XCode: Version 13.3 (13E113)

:beetle: What is the observed behavior?

Build fails when building for ios.

:beetle: What is the expected behavior?

It should not fail building.

:beetle: Please post your code:

N/A

: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?

aprilmintacpineda commented 2 years ago

Possible workaround:

Applying the following patch, works:

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;