v3 Audio Unit Extension: Unable to load Audio Unit View Controller into container view

I'm trying to develop v3 Audio Unit Extensions for MacOS. I'll have several of these and so I'd like to create a reusable window/panel architecture that contains buttons like Process, Cancel, Bypass... these buttons should be the same for any audio unit chosen. I want to load the audio unit UI within a container view in that window/panel template. Something like the following:


Window/Panel Template
...............................................
| |
| ................................ |
| | | |
| | container view | |
| | AU UI goes here | |
| | | |
| ............................... |
| |
| Button 1. Button 2 |
...............................................


I'm instantiating the audio unit successfully and calling requestViewControllerWithCompletionHandler to get the Audio Unit UI. Then I'm adding the returned auViewController as a childViewController to the window's view controller and adding the auViewController.view as a subview of the containerView. This doesn't work and I can't figure out why. The returned auViewController is of type AURemoteAudioUnitViewController... not my audio unit's view controller class. Note sure if that has anything to do with it, but I don't seem to be touching my class at all. The code is below.

Note that, if I set the window controller's contentViewController to the auViewController returned by requestViewControllerWithCompletionHandler (i.e. auwindowController.contentViewController = auViewController) it does work. I can see the audio unit's UI and control the sound using params in real-time. All seems to be fine except that I can't seem to figure out how to embed the audio unit UI into a view container of another window. Am I going about this the wrong way? Any help would be greatly appreciated!

// CODE

    [AVAudioUnit instantiateWithComponentDescription: description options: kAudioComponentInstantiation
LoadOutOfProcess
completionHandler:^(AVAudioUnit* audioUnit, NSError *error)
    {
        if(error == noErr)
        {
            if(YES == [[audioUnit AUAudioUnit] providesUserInterface])
            {
                [[audioUnit AUAudioUnit] requestViewControllerWithCompletionHandler: ^(AUViewControllerBase *auViewController)
                {
                    NSStoryboard *austoryboard = [NSStoryboard storyboardWithName:@"AUPluginWindow" bundle:nil];
                    AUWindowController *au
windowController = [austoryboard instantiateControllerWithIdentifier:@"AUWindowController"];

                    AUPanelViewController *au
panelViewController = (AUPanelViewController*)auwindowController.contentViewController;

                    NSWindow *auWindow = [au
windowController window];
                    [auWindow setFrame: NSMakeRect(100, 100, 600, 300) display: YES];
                    [auWindow makeKeyAndOrderFront: self];

                    // get containerView - IBOutlet in AUPanelViewController
                    NSView *containerView = [aupanelViewController getContainerView];

                    // Add the AudioUnitViewController as child to the window's view controller
                    [au
panelViewController addChildViewController: auViewController];
                    [[auViewController view] setFrame: containerView.bounds ];

                    // add audio unit view as subview to containerView
                    [containerView addSubview: auViewController.view];
                }];
            }
        }
        else
            NSLog(@"Error instantiating audio unit");

    }];
I would suggest you start by looking at your view hierarchy in Xcode's view debugger. You should check:
  1. Whether all the views you expect actually exist.

  2. If your AU view is masked behind some other view.

  3. Whether all the views have the expected size.

You should also check whether you end up with 2 instances of (say) your window. You might have a window without the child view controller in front of a similar window with the child view controller. Needless to say, that leads to some very confusing debugging headaches, if you're not aware of what's going on.

If you can't make any progress, it would be worth making a sample project that demonstrates the issue, then use a tech support incident (https://developer.apple.com/support/technical) to get help from one of the DTS engineers.
Solved... I had the wrong value for the AudioComponentBundle key in the audio unit's info.plist.
v3 Audio Unit Extension: Unable to load Audio Unit View Controller into container view
 
 
Q