Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The main branch is broken on MacOS #413

Closed
renancaraujo opened this issue Oct 9, 2024 · 1 comment
Closed

The main branch is broken on MacOS #413

renancaraujo opened this issue Oct 9, 2024 · 1 comment

Comments

@renancaraujo
Copy link
Contributor

Package version
Current main (a6de25f)

Environment

  • OS: macOS

Describe the bug

The current build includes AVSession, which is not available on macos. The build breaks on mac since the source is shared between iOS and macOS.

To Reproduce

Steps to reproduce the behavior:

  1. on the apps pubspec, depend on the project repo with ref on a6de25f11d07453b8827ba0298cff619cb681e1f
  2. Build for macos
  3. Build will break with a message similar to:
record_darwin/darwin/Classes/RecordConfig.swift:71:25: error: 'AVAudioSession' is unavailable in macOS
  let audioCategories: [AVAudioSession.CategoryOptions]

Expected behavior

App to build normally

Additional context

One may add consitional declarations to fix this problem:

struct IosConfig {}

#if os(iOS)
extension IosConfig {
    let audioCategories: [AVAudioSession.CategoryOptions]

    init(map: [String: Any]) {
      let comps = map["audioCategories"] as? String
      let options: [AVAudioSession.CategoryOptions]? = comps?.split(separator: ",").compactMap {
        switch $0 {
        case "mixWithOthers":
            .mixWithOthers
        case "duckOthers":
            .duckOthers
        case "allowBluetooth":
            .allowBluetooth
        case "defaultToSpeaker":
            .defaultToSpeaker
        case "interruptSpokenAudioAndMixWithOthers":
            .interruptSpokenAudioAndMixWithOthers
        case "allowBluetoothA2DP":
            .allowBluetoothA2DP
        case "allowAirPlay":
            .allowAirPlay
        case "overrideMutedMicrophoneInterruption":
          if #available(iOS 14.5, *) { .overrideMutedMicrophoneInterruption } else { nil }
        default: nil
        }
      }
      self.audioCategories = options ?? []
    }
}
#endif
@llfbandit
Copy link
Owner

Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants