Bad Access Error when using Plugin Host

Hi,

I am trying to follow this tutorial: https://youtu.be/PaKXRm6RZF4?si=pAcEOu8uxhCfxRsY which I realise is quite old.

At about 13:05 he compiles the code and adds the synth to the Plugin Host window. He then double clicks the plugin to bring up the GUI. When I double click mine, I am taken to a window in XCode called juce_component and there is this error: JUCE Message Thread (1): EXC_BAD_ACCESS (code=2, address=0x16f603ff8). It is not clear to me exactly where the problem in the code is.

I have tried to search for a solution and have found this: https://forum.juce.com/t/juce-message-thread-1-exc-bad-access/26062 but I do not think it is the exact same problem.

If anyone has had this happen before and can help I would really appreciate it. I am also happy to share the code, but as I said, I do not know the location of my mistake.

Any help would be much appreciated.