I am playing with Swift and noticed that Swift does not allow to create CFFunctionPointers. It can only pass around and reference existing ones.
As for example Core
Well, you can create a function pointer.
var ump = UnsafeMutablePointer<((UnsafePointer, UnsafeMutablePointer, UnsafeMutablePointer ) -> Void)>.alloc(1)
ump.initialize(MyMIDIReadProc)
let cp = COpaquePointer(ump)
let fp = CFunctionPointer<((UnsafePointer, UnsafeMutablePointer, UnsafeMutablePointer ) -> Void)>(cp)
status = MIDIDestinationCreate(midiClient,
name,
fp,
etc.
It doesn't work though with Core MIDI.
thread #7: tid = 0x713b7, 0x7a1541f0, stop reason = EXC_BAD_ACCESS (code=2, address=0x7a1541f0)
frame #0: 0x7a1541f0
frame #1: 0x00159295 CoreMIDI`LocalMIDIReceiverList::HandleMIDIIn(void*, OpaqueMIDIEndpoint*, void*, MIDIPacketList const*) + 117
BTW., you cannot have a bridging header if your MIDI code is in a framework you're writing.