Why is MIDIInputPortCreate deprecated? What's the new alternative?

I'm reading up about how to use CoreMIDI to receive input from a MIDI keyboard. I found this excellent playground code to get going:
https://gist.github.com/jemmons/847cdc494eb332ba1b9f50f18ee8616a#file-receive-data-swift

This certainly works, but it makes use of MIDIInputPortCreate, which according to the documentation, is now deprecated:
https://developer.apple.com/documentation/coremidi/1495225-midiinputportcreate

The thing is though, I can't find any alternatives. And if it was deprecated, I would have expected the related functions, MIDIClientCreate, MIDIPortConnectSource, and MIDIOutputPortCreate to similarly be deprecated in favor of some new approach.

But those related functions are not. In light of that, what is the reason that MIDIInputPortCreate, and what is the alternative method to use if it is deprecated?
Answered by OOPer in 626262022

what is the alternative method to use if it is deprecated?

The header doc (you can see with Context menu > Jump to Definition) says renamed: "MIDIInputPortCreateWithProtocol(_:_:_:_:_:)".

MIDIInputPortCreateWithProtocol(_:_:_:_:_:)

what is the reason that MIDIInputPortCreate

As found in the doc of MIDIInputPortCreateWithProtocol, it has a parameter MIDIProtocolID. I guess Apple wants developers to be ready for MIDI 2.0.

Accepted Answer

what is the alternative method to use if it is deprecated?

The header doc (you can see with Context menu > Jump to Definition) says renamed: "MIDIInputPortCreateWithProtocol(_:_:_:_:_:)".

MIDIInputPortCreateWithProtocol(_:_:_:_:_:)

what is the reason that MIDIInputPortCreate

As found in the doc of MIDIInputPortCreateWithProtocol, it has a parameter MIDIProtocolID. I guess Apple wants developers to be ready for MIDI 2.0.

Thank's so much! I think maybe I need to update my Xcode, because it's not been deprecated in my version since the header file actually doesn't have a deprecated annotation (but scrolling around, I see other functions do which should have been a flag that I was behind). It seems like the online docs should surface that deprecation info though. Am I just missing where it says that in the online doc?

Am I just missing where it says that in the online doc?

In Xcode 12 beta 4, you can see this deprecation annotation on MIDIInputPortCreate.
Code Block
@available(iOS, introduced: 4.2, deprecated: 100000, renamed: "MIDIInputPortCreateWithProtocol(_:_:_:_:_:)")


Header docs and online docs may have some differences often in new APIs.
But if you use the latest version of Xcode and find some significant differences in the docs, you may send a feedback about the docs.
My problem is that the documentation says that MIDIInputPortCreateWithProtocol is only available in macOS 11.0 or later.
This means that is only usable in BigSur. I am trying to create some sample MIDI programs, but I am getting errors.


When I run that code, I get the following error.

BRossTools[2569]: BUG IN CLIENT OF LIBDISPATCH: Assertion failec: Block was expected to run on queue [com.apple.main-thread]

The error when I depressed a key on the keyboard.

Who do I send feedback to about the docs. I have a number of issues. Does anybody have a short example that reads MIDI signals from a keyboard. I can put my working code on GitHub if people want to look at it. All of the tutorials seem to be years out of date.

I found the problem. One of the subroutines was indirectly calling one of the UI methods. I placed code in place to insure that it would run on the main

Why is MIDIInputPortCreate deprecated? What's the new alternative?
 
 
Q