iosswiftxcodesyntax-erroravfoundation

Xcode 14.2 Play Sound Error:AddInstanceForFactory: No factory registered for id <CFUUID


I'm taking Angela Yu's online course to learn to build app. In one of the module (Xylophone) it's using AVFoundation to play sounds. I use Xcode 14.2 on macOS 13.

When I run the following code, I got an error/warning message (Xylophone[5255:159387] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID). It didn't stop me from running the app and the sound can be played indeed, but I wonder how I can get rid of the message.

import UIKit
import AVFoundation
//var player: AVAudioPlayer!

class ViewController: UIViewController {
    
    var player: AVAudioPlayer!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func keyPressed(_ sender: UIButton) {
        playSound()
    }
    
    func playSound() {
        let url = Bundle.main.url(forResource: "C", withExtension: "wav")
        player = try! AVAudioPlayer(contentsOf: url!)
        player.play()
                
    }
}

Also, I tried moving the var statement to right after the import statement according to this question: Swift 5.1 Error: [plugin] AddInstanceForFactory: No factory registered for id <CFUUID but the message is still there. And tried replacing "!" with "?" but still not working.


Solution

  • The message only occurs when using a simulator with AVFoundation. If you test on an iPhone or an iPad the message will not occur. This message is just informational and is not an indication of an error.

    Some of Apple's frameworks throw messages that are irrelevant to developers although probably helpful to Apple engineers for internal reasons. Messages like these are sometimes removed in Apple's updates. Once you're familiar with the message it can be ignored.