Skip to content

iOS build error #884

Description

@vitoriamacena

🪲 Description

Compilation error when building iOS project.

🪲 What is the observed behavior?

The build fails with the following error:

  (/node_modules/react-native-sound/ios/RNSound.mm:180:73)

  178 | #pragma mark - Audio Control Methods
  179 | 
> 180 | RCT_EXPORT_METHOD(prepare:(NSString *)fileName key:(double)key options:(JS::NativeSoundIOS::SoundOptionTypes &)options callback:(RCTResponseSenderBlock)callback ) {
      |                                                                         ^ use of undeclared identifier 'JS'
  181 |     NSError *error;
  182 |     NSURL *fileNameUrl;
  183 |     AVAudioPlayer *player;


  (/node_modules/react-native-sound/ios/RNSound.mm:180:73)

  178 | #pragma mark - Audio Control Methods
  179 | 
> 180 | RCT_EXPORT_METHOD(prepare:(NSString *)fileName key:(double)key options:(JS::NativeSoundIOS::SoundOptionTypes &)options callback:(RCTResponseSenderBlock)callback ) {
      |                                                                         ^ expected a type
  181 |     NSError *error;
  182 |     NSURL *fileNameUrl;
  183 |     AVAudioPlayer *player;

🪲 What is the expected behavior?

The library should compile successfully on iOS.

🪲 Please post your code:

  Sound.setCategory('Alarm', true);

  const alarm = new Sound(
    'critical_notification.mp3',
    Sound.MAIN_BUNDLE,
    error => {
      if (error) {
        console.log('Failed to load the sound', error);
        return;
      }

      alarm.play(success => {
        if (success) {
          console.log('Successfully finished playing');
        } else {
          console.log('Playback failed due to audio decoding errors');
        }
      });
    }
  );

💡 Is there a workaround?

Not a long-term solution that I am aware of.

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

Yes, I can help if guidance is provided.

Is your issue with...

  • iOS
  • Android
  • Windows

Are you using...

  • React Native CLI (e.g. react-native run-android)
  • Expo
  • Other: (please specify)

Which versions are you using?

  • React Native Sound: 0.13.0
  • React Native: 0.76.9
  • iOS:
  • Android:
  • Windows:

Does the problem occur on...

  • Simulator
  • Device

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

  • Device: iPhone 14

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions