Category

Swift 1.2 beta2 and CoreMIDI

Swift Language

Swift 1.2 beta2 and CoreMIDI

Someone is actually working on CoreMIDI with Swift.

N.B.

Apple has improved Core MIDI support for Swift since this was written.

The Problem

Prior to Swift 1.2, various CoreMIDI types defined in MIDIServices.h were architecture dependent. Like this:

This mean that you had to deal with nonsense like this:

I blogged about the problem with creating a MIDI client ref in a 32-bit architecture. (Hint: don’t try).

Now in Swift 1.2 beta wer get this:

Those Opaque structs are now history. Yay.

But…

Let’s look at the MIDI Services reference.

Here’s a gem. Note the return type.

You would use this like so:

ItemCount is defined in MacTypes. Or it was until now. Right now there is a commment for it but no definition.
D’oh!

Workaround. Go ahead and define it yourself as it was pre-Swift 1.2.

Or just don’t use it.

Table of Contents

Summary

There is progress with using CoreMIDI from Swift.
There are still potholes though.

Resources

One Reply to “Swift 1.2 beta2 and CoreMIDI”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.