Mithronn / react-native-real-time-audio-stream

MIT License
3 stars 0 forks source link

Unable to compile iOS app - Could not build module 'React' #2

Open smfunder opened 7 months ago

smfunder commented 7 months ago

NOTE: I totally understand the code for OPUS support runs only in Android while in iOS it just sends the raw data but...

After installing the library into my React Native project it just works for Android, but in iOS I cannot even compile the app. Initially it throws that new EventEmitter() cannot receive a null parameter so I was able to fix by moving the RNRealTimeAudioStream.podspec to the root of the library and updating this line to:

s.source_files = 'iOS/*.{h,m}'

But after doing that, the app doesn't compile for iOS with these errors:

Captura de pantalla 2024-03-11 a la(s) 12 29 29

I tried by cleaning up the pods folder and lock file.

I tried by adding this line to the pod file:

pod 'RNRealTimeAudioStream', :path => '../node_modules/react-native-real-time-audio-stream'

I tried cleaning up the project.

And I even tried the non-modular option to yes:

Captura de pantalla 2024-03-11 a la(s) 12 32 53

Any suggestion or help on getting this to build with iOS?

Thanks

smfunder commented 7 months ago

I was able to build iOS finally. What I had to do for future reference is to add this on the pod file (I'm running M2 chip):

  post_integrate do |installer|
    compiler_flags_key = 'COMPILER_FLAGS'
    project_path = 'Pods/Pods.xcodeproj'

    project = Xcodeproj::Project.open(project_path)
    project.targets.each do |target|
      target.build_phases.each do |build_phase|
        if build_phase.is_a?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
          build_phase.files.each do |file|
            if !file.settings.nil? && file.settings.key?(compiler_flags_key)
              compiler_flags = file.settings[compiler_flags_key]
              file.settings[compiler_flags_key] = compiler_flags.gsub(/-DOS_OBJECT_USE_OBJC=0\s*/, '')
            end
          end
        end
      end
    end
    project.save()
  end

Also, to make sure to remove the RNLiveAudioStream module to avoid duplicated symbols.