Apple's iDAM can be used to route MIDI to and from iOS devices over a USB connection. However this only works for internal MIDI. You can't route an external keyboard or other controller attached to the MAC to iOS via iDAM. This article shows how to do it using the free MacOS utility MidiPipe.
There are many other things you can do with MidiPipe. It's well worth looking into, and highly encouraged to make a donation to the developer for their generous work.