Skip to content

iOS build errorΒ #884

Open
Open

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

  1. pSapien commented on Dec 10, 2025

    @pSapien

    @vitoriamacena did you find any fix to this issue?

  2. vitoriamacena commented on Dec 10, 2025

    @vitoriamacena
    Author

    @vitoriamacena did you find any fix to this issue?

    No, I ended up adding it to my react-native.config.js then use only for Android.

    // react-native.config.js
    
    module.exports = {
      dependencies: {
        'react-native-sound': {
          platforms: {
            ios: null,
          },
        },
      },
    };
    
  3. abdulmateen-pb commented on Jan 14, 2026

    @abdulmateen-pb

    The current release destroying everything ios build is never successful just waiting for the stable release please release stable version,

  4. dubiao commented on Mar 10, 2026

    @dubiao

    try this:
    find the prepare: fileName function in node_modules/react-native-sound/ios/RNSound.mm, and replace it with

    #ifdef RCT_NEW_ARCH_ENABLED
    RCT_EXPORT_METHOD(prepare:(NSString *)fileName key:(double)key options:(JS::NativeSoundIOS::SoundOptionTypes &)options callback:(RCTResponseSenderBlock)callback ) {
    #else
    RCT_EXPORT_METHOD(prepare:(NSString *)fileName key:(double)key options:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback ) {
    #endif
    

    I am running on Old Arch, and dont have JS in runtime. This fix it to dict type for options.

  5. chichilatte commented on May 27, 2026

    @chichilatte

    We had the same problem with react-native-sound, having turned off new architecture in our project until the react-native-firebase packages catch up.

    The solution was to add this to the ios/Podfile...

      post_install do |installer|
    
        # react-native-sound v0.13.0: new arch C++ types not guarded
        installer.pods_project.targets.each do |t|
          if t.name == 'RNSound'
            t.build_configurations.each { |c| c.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'RCT_NEW_ARCH_ENABLED=0'] }
          end
        end
    
      end

    Actually, we're using expo, so had to implement this solution as an app.json plugin so that it could survive prebuild cleans (they wipe the ios folder).

    Note: The above code was generated by DeepSeek, so ymmv. Works for us!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions