Unable to detect midi events in Logic Pro X

I have a simple audio plugin which displays the midi note number of the last note on event. In my processBlock, I have the following code:

MidiBuffer::Iterator iterator (midiMessages);
MidiMessage midiMessage;
int samplePosition;

while (iterator.getNextEvent (midiMessage, samplePosition))
    if (midiMessage.isNoteOn())
        midiNote = midiMessage.getNoteNumber();

When I run my plugin in the Juce Plugin Host, the midiNote variable is updated accordingly as I play notes. However, when I run my plugin inside of Logic, the midiNote variable never changes.

Any idea why this is happening?

Did you tick the box that your plug-in wants midi input in the Projucer?
You need to do this and override AudioProcessor's bool acceptsMidi() const method to return true:

 bool acceptsMidi() const override     { return true; }

Fabian thanks for the reply, yes I have done this. And indeed the plugin works correctly in the JUCE Plugin Host and I can detect midi, but not when loaded into Logic. I also tried loading it into Maschine and no midi detected there either.

Very strange.

Not sure, there must be something wrong in your code. You can try the JucePluginDemo or the MultiOutSynth sample in JUCE. Both work fine in Logic and Maschine. Try comparing your code with the code of those plug-ins line-by-line to see if you spot any difference.

If I load the JucePluginDemo as a channel strip effect, I am only able to play notes by clicking on the GUI keyboard, but not with my external midi keyboard. However, if I load it in an instrument slot as a Midi-controlled Effect, I am then able to play with my external keyboard. So perhaps Logic only passes midi to Instruments and Midi-controlled effects, but not channel strip effects.