AVKit Error

Errors are here:

libMobileGestalt MobileGestaltCache.c:38: No persisted cache on this platform.

HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004

HALDefaultDevice::Initialize: couldn't add the default input device listener, Error: 268435460 (\^P)

and many HALCADClient and HALDefaultDevice Errors...


I'm developing voice recorder app with SwiftUI 2.0 in Simulator but starting with Initializing the audio session, it begins errors above written.

Code is here:

import Foundation
import SwiftUI
import Combine
import AVKit


class UserSettings: ObservableObject {

    @Published var isRecording: Bool = false    
    @Published var session: AVAudioSession!
    @Published var recorder: AVAudioRecorder!
    @Published var audios: [URL] = []

  
    init()
    {
        do {
            session = AVAudioSession.sharedInstance()
            try session.setCategory(.playAndRecord)
            session.requestRecordPermission { (status) in
// Alert --

            }

        }

        catch {
            print(error.localizedDescription)

        }

    }

}


above code worked well in Xcode 11.

I'm developing it in Xcode 12 beta 3 with simulators..


What's the problem?


I tested the project in Xcode 12 beta 2... It worked without those errors... It's only issue for Xcode 12 beta 3 until now...
Hello! I'm getting the similar error messages in a SwiftUI application in XCode 12 Beta 3 when I am trying to add sound to the .

For my app it seems that the initialization of AVAudioPlayer is what triggers the errors within the iOS Simulator.

Here's the relevant snippet of code:

Code Block swift
import AVFoundation
var audioPlayer: AVAudioPlayer?
func playSound(sound: String, type: String) {
if let path = Bundle.main.path(forResource: sound, ofType: type) {
do {
print("Want to play sound! file: \(sound) type: \(type)")
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
audioPlayer?.play()
} catch {
print("ERROR: Could not find and play the sound! file: \(sound) type: \(type)")
}
}
}


Errors:

Code Block
2020-08-02 11:01:42.254964-0500 myapp[1720:143366] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-08-02 11:01:47.256608-0500 myapp[1720:143366] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-08-02 11:01:47.257136-0500 myapp[1720:143366] HALDefaultDevice::Initialize: couldn't add the default input device listener, Error: 268435460 (\^P)
2020-08-02 11:01:52.257906-0500 myapp[1720:143366] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-08-02 11:01:52.258145-0500 myapp[1720:143366] HALDefaultDevice::Initialize: couldn't add the default output device listener, Error: 268435460 (\^P)
2020-08-02 11:01:57.259596-0500 myapp[1720:143366] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-08-02 11:01:57.260023-0500 myapp[1720:143366] HALDefaultDevice::Initialize: couldn't add the default system output device listener, Error: 268435460 (\^P)
2020-08-02 11:02:02.260790-0500 myapp[1720:143366] HALCADClient::ConnectToServer: failed to find the AHS sub-server port, Error: 0x10000004
2020-08-02 11:02:02.261091-0500 myapp[1720:143366] HALDefaultDevice::Initialize: couldn't add the default shared output device listener, Error: 268435460 (\^P)
2020-08-02 11:02:02.261927-0500 myapp[1720:143366] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000038849a0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-08-02 11:02:02.262654-0500 myapp[1720:143366] AudioObjectSetPropertyData: no object with given ID 0
2020-08-02 11:02:02.262870-0500 myapp[1720:143366] 83: Failed to set processVolumeScalar on device. Error: 560947818
Want to play sound! file: sound type: mp3


I'm downloading beta 2 to check if the problem persists there and I will follow up.

Update: I've upgraded to Big Sur beta 3 and this problem goes away!

Sound is working fine in the iOS Simulator using Xcode Version 12.0 beta 3 (12A8169g) with macOS 11.0 Beta (20A5323l) and the logged errors I pasted above are gone.
I get the same errors on Xcode 12 Beta 3 with using AVFoundation. I tested it on a physical device and everything worked fine so it's just a bug with the simulators.
I am also facing same issue while playing video
Audio appears to be broken when using Xcode 12 Beta 3 with iOS 14 in the simulator.

As a workaround you can install an iOS 13.0 simulator (Preferences -> Components) to run your app in.
Also seeing this behaviour and sadly it's still present in Xcode 12 beta 4 (running on Catalina).

Log output of the sample app I attached to my feedback report:

https://gist.github.com/lukeredpath/0ba9ea748cf0ad90a64b5fa1dde4c3a1

Feedback number FB8116155

Please file a feedback using Feedback Assistant, maybe quoting the above number. The more reports the more likely this will get looked at.

I haven't tried using an iOS 13 simulator as a workaround but note that this issue also seems to affect live previews in Xcode too.
Receiving similar errors in 12.3 beta for my Objective C app. Audio will not play at all.
Similar errors for SKAction.playSoundFileNamed() on xcode 12.0 beta 3, swift 5.2 app.
Well this stinks since it's been broken since Beta3. I upgraded my phone to IOS14 yesterday and was wondering why audio and even UISwitches were not working and wonky.

Testing in the IOS 13.5 simulator is not a workaround as we're developing code for IOS 14!

I will file another feedback bug item.
We are seeing this as well. This appears to be a known issue that Apple is working to fix, per https://developer.apple.com/forums/thread/650741
Thanks for the pointer, but it seems the last post was from over a month ago. Maybe a bump in that thread may get them to look at it again.


Fixed for me in Xcode 12 beta 5
AVKit Error
 
 
Q