title: Swift hosting AUv3 with AVAudioEngine crashes in iOS simulator
body: <p>I started a new iOS application, where I am hosting a AUv3 Plugin, which I created via an AudioUnit Extension. I am basically using the template, which Apple has provided me with. My main application is hosting the AUv3. The following code works on my device ( iPad Pro 11 - iOS 14 ) but in the simulator ( iPhone 11 - iOS 14 ) I get the following error message:</p>
  <blockquote>
  <p>2020-10-15 21:07:36.786306+0200 MyApp[2132:84039] [plugin]
  AddInstanceForFactory: No factory registered for id &lt;CFUUID
  0x600001d074c0&gt; F8BB1C28-BAE8-11D6-9C31-00039315CD46</p>
  <p>2020-10-15 21:07:37.124600+0200 MyApp[2132:83972] EXCEPTION:
  os_eventlink_activate failed (45)</p>
  <p>2020-10-15 21:07:37.125009+0200
  MyApp[2132:83972] [i-aa] AUAudioUnit_XPC.mm:665:-[AUAudioUnit_XPC
  allocateRenderResourcesAndReturnError:]: render pipe user creation
  failure (Error Domain=NSOSStatusErrorDomain Code=-1 &quot;(null)&quot;)</p>
  <p>2020-10-15 21:07:37.125389+0200 MyApp[2132:83972] [avae]<br />
  AVAEInternal.h:109   [AVAudioEngineGraph.mm:1389:Initialize: (err =
  AUGraphParser::InitializeActiveNodesInOutputChain(ThisGraph,
  kOutputChainOptimizedTraversal, *GetOutputNode(),
  isOutputChainActive)): error -1 ERROR: The operation couldn’t be
  completed. (com.apple.coreaudio.avfaudio error -1.)</p>
  </blockquote>
  <p>ViewController.swift</p>
  <pre><code>import UIKit
  import AVFoundation
  import CoreAudioKit
  
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var auView: UIView!
      
      var avUnit:AVAudioUnit?
      var engine:AVAudioEngine!
          
      override func viewDidLoad() {
          super.viewDidLoad()
          
          self.engine = AVAudioEngine()
          
          do {
              try AVAudioSession.sharedInstance().setMode(.default)
              try AVAudioSession.sharedInstance().setPreferredSampleRate(44100)
              try AVAudioSession.sharedInstance().setCategory(.playback, options: [.allowBluetooth, .allowBluetoothA2DP, .mixWithOthers])
              try AVAudioSession.sharedInstance().setActive(true)
              
          }catch let error{
              print(&quot;error \(error.localizedDescription)&quot;)
          }
          
          // Retrieve audio unit components by description.
          let description = AudioComponentDescription(componentType: kAudioUnitType_MusicDevice,
                                                      componentSubType: 0x6775616e,
                                                      componentManufacturer: 0x5775616e,
                                                      componentFlags: 0,
                                                      componentFlagsMask: 0)
          
          
          AVAudioUnit.instantiate(with: description, options: []) { avAudioUnit, error in
              
              guard error == nil else {
                  DispatchQueue.main.async { /* Show error message to user. */ }
                  return
              }
              
              guard let aUnit = avAudioUnit else { return }
              self.avUnit = aUnit
              
              //let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 2, interleaved: false)!
              let formatOutput = self.engine.mainMixerNode.outputFormat(forBus: 0)
              let formatAU = aUnit.outputFormat(forBus: 0)
  
              self.engine.attach(aUnit)
              self.engine.connect(aUnit, to: self.engine.mainMixerNode, format: formatAU)
              self.engine.connect(self.engine.mainMixerNode, to: self.engine.outputNode, format: formatOutput)
              
              
              do {
                  
                  try self.engine.start()
                  
              } catch let error {
                  print(error.localizedDescription)
              }
              
              self.addPluginView()
  
          }
          
      }
      
      
      private func addPluginView() {
  
          self.avUnit?.auAudioUnit.requestViewController(completionHandler: { plugInViewController in
              
              if plugInViewController != nil{
                  
                  if let pluginView = plugInViewController!.view{
                      
                      pluginView.frame = self.auView.bounds
                      self.auView.addSubview(pluginView)
                      
                  }
                  
              }
              
          })
          
      }
      
  }
  </code></pre>
  <p>Is it a problem inside the AVAudioEngine..?
  Any help highly appreciated.</p>