I know that there are threads where this error message appears but they do not really supply an answer to the problem, this is why I decided open up another thread and ask again
Your session.setCategory
is outdated and has to be renamed:
Incorrect:
try! session.setCategory(AVAudioSessionCategoryPlayAndRecord, with:AVAudioSessionCategoryOptions.defaultToSpeaker)
Correct:
try! session.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: AVAudioSession.CategoryOptions.defaultToSpeaker)