How to Add an External VST to a Track

This is a newbie question, but I can’t seem to find an example anywhere. All the examples use the built-in plugins and not the external VST3 plugins loaded with JUCE. I’ve successfully loaded a VST3 plugin with JUCE, however, I need an xmlType using the edit plugin cache to create a new plugin pointer in order to insert it into a track. Here is how I’m loading the specific plugin:

// Load all the vst plugins from the dependencies folder
File pluginDirectory = File::getCurrentWorkingDirectory().getChildFile("..\\..\\..\\dependencies\\VST3").getFullPathName();
addVSTsFromDirectory(pluginDirectory, engine.getPluginManager().knownPluginList);
// loop through the known plugins and print their ids
for (auto plugin : engine.getPluginManager().knownPluginList.getTypes())
{
    if (plugin.name.compare("Anaglyph") == 0) {
        anaglyphPluginID = plugin.createIdentifierString();
		DBG("Anaglyph found");
	}
}

And then here is where I’m trying to add the plugin to a track:

    auto anaglyphDescription = engine.getPluginManager().knownPluginList.getTypeForIdentifierString(anaglyphPluginID);
    String errorMessage;
    PluginDescription description;
    auto plugin = defaultEdit->getPluginCache().createNewPlugin(ExternalPlugin::xmlTypeName, {});
    auto track = getAudioTracks(*defaultEdit)[0];
    track->pluginList.insertPlugin(plugin, -1, nullptr);

But this is obviously not linking to the actual anaglyph plugin. Any help would be appreciated!

I think you need to pass the PluginDescription to the createPlugin function.

    auto plugin = defaultEdit->getPluginCache().createNewPlugin(ExternalPlugin::xmlTypeName, anaglyphDescription);

Your PluginDescription description; line is unused.