Hi, I try to record audio on the iPhone with the AVAudioRecorder and Xcode 26.0.1.
Maybe the problem is that I can not record audio with the simulator. But there's a menu for audio.
In the plist I added 'Privacy - Microphone Usage Description' and I ask for permission before recording.
if await AVAudioApplication.requestRecordPermission() {
print("permission granted")
recordPermission = true
} else {
print("permission denied")
}
Permission is granted.
let settings: [String : Any] = [
AVFormatIDKey: kAudioFormatMPEG4AAC,
AVSampleRateKey: 12000,
AVNumberOfChannelsKey: 1,
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]
recorder = try AVAudioRecorder(url: filename, settings: settings)
let prepared = recorder.prepareToRecord()
print("prepared started: \(prepared)")
let started = recorder.record()
print("recording started: \(started)")
started is always false and I tried many settings.
Error messages
AddInstanceForFactory: No factory registered for id <CFUUID 0x600000211480> F8BB1C28-BAE8-11D6-9C31-00039315CD46
AudioConverter.cpp:1052 Failed to create a new in process converter -> from 0 ch, 12000 Hz, .... (0x00000000) 0 bits/channel, 0 bytes/packet, 0 frames/packet, 0 bytes/frame to 1 ch, 12000 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame, with status -50
AudioQueueObject.cpp:1892 BuildConverter: AudioConverterNew returned -50
from: 0 ch, 12000 Hz, .... (0x00000000) 0 bits/channel, 0 bytes/packet, 0 frames/packet, 0 bytes/frame
to: 1 ch, 12000 Hz, aac (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
prepared started: true
AudioQueueObject.cpp:7581 ConvertInput: aq@0x10381be00: AudioConverterFillComplexBuffer returned -50, packetCount 5
recording started: false
All examples I find are the same, but apparently there must be something different.