I am experiencing the same issue but only when I run it on my iPhone X from Xcode. None of the code changes made a difference for me.
2018-11-24 21:45:31.227497-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver) |
2018-11-24 21:45:31.285499-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver) |
2018-11-24 21:45:31.285741-0500 Pitch Perfect[343:20265] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker) |
Original syntax:
Initial setting
try recordingSession.setCategory(.playAndRecord, mode: .default, options: [])
Changed mode
try recordingSession.setCategory(.playAndRecord, mode: .spokenAudio, options: [])
try recordingSession.setActive(true, options: [])
Attempted fix syntax:
try recordingSession.setCategory(.playAndRecord, mode: .spokenAudio, options: .defaultToSpeaker)
try recordingSession.setActive(true, options: .notifyOthersOnDeactivation)
Also tried:
try recordingSession.setCategory(.playAndRecord, mode: .default)
try recordingSession.setActive(true)
I'm running Xcode Version 10.1 (10B61) on macOS Mojave Version 10.14.1 (18B75) with a deployment target of 12.1 using Swift 4.2 settings
iPhone X is running iOS Version 12.1 (16B92)
Another issue I am seeing besides the console messages is my playback is erratic on my iPhone but not in the simulator. Tapping different sound filter buttons on my iPhone doesn't always play the related audio file. Usually takes multiple taps before it responds but it does not do this on the simulator.
On the simulator I get this message, but it does not display when I run on my iPhone:
2018-11-24 22:37:10.669600-0500 Pitch Perfect[13586:24145857] 317: ca_debug_string: inPropertyData == NULL