I'm trying to make an app that can send MIDI data over Bluetooth from my iPhone to my Mac. I'm using AudioKit as a framework for the MIDI aspect, and it's working great over a wired connection. I can't figure out how to implement MIDI over Bluetooth though.
I found the
CABTMIDILocalPeripheralViewController page here: https://developer.apple.com/documentation/coreaudiokit/cabtmidilocalperipheralviewcontroller
, which looks promising, but I'm confused about how to use it.I'd really like to implement it using SwiftUI as opposed to UIKit, because the rest of the app is made with SwiftUI. Could someone please show me how I could use this in SwiftUI to make my iPhone discoverable as a Bluetooth MIDI device?
I found some sample code written with UIKit, but I'd like to translate this to SwiftUI:
import UIKit
import CoreAudioKit
import CoreMIDI
class ViewController: UIViewController {
var localPeripheralViewController:CABTMIDILocalPeripheralViewController?
override func viewDidLoad() {
super.viewDidLoad()
localPeripheralViewController = CABTMIDILocalPeripheralViewController()
}
@IBAction func someAction(sender: AnyObject) {
self.navigationController?.pushViewController(localPeripheralViewController!, animated: true)
}
}
Thank you,
Jack