"Couldn't find MIDI network driver" crash in iOS 13 simulators
Asked Answered
H

3

12

In Xcode 11 beta 6's iOS 13 simulators I'm getting a crash when enabling the MIDI Network Session.

I was able to replicate by adding the following lines to AppDelegate's didFinishLaunching:WithOptions: in a fresh project:

MIDINetworkSession.default().isEnabled = true
MIDINetworkSession.default().connectionPolicy = .anyone

When run in an iOS 13 simulator the app will crash at the first of these lines, printing "Couldn't find MIDI network driver" to the console. iOS 12 and earlier simulators are unaffected.

Strangely though it seems that not all of my iOS 13 simulators are affected. It seems that any iOS 13 simulators I had used from Xcode 11 beta 4 and earlier work correctly. The only simulators affected may be ones I used for the first time in Xcode 11 beta 5 onwards.

I'm assuming this is a beta software bug, and have already filed the bug with Apple. But I felt it smart to document here in case anyone else comes across it.


Update: 2019-09-11

This is still a problem for me with the simulators in the Xcode 11.0 GM seed (including the new iPhone 11 models).


Update: 2019-09-30

Issue still exists in Xcode 11.1 GM seed. I followed the steps in Evan's answer and that appeared to fix it.

Horta answered 21/8, 2019 at 8:47 Comment(2)
2019-09-21 MIDINetworkSession.default().isEnabled = true MIDINetworkSession.default().connectionPolicy = .anyone Didn't work for me on XcodeVersion 11.0 (11A420a) public release. This looks like a very annoying problem. We're just about releasing an app!Flickinger
@Flickinger Are you getting that on device, or just on the simulator?Horta
L
11

I was getting the same error as you and this frusturated me. I searched for a solution for four days, and finally found one. I hope this will help you as well! Please follow these steps carefully:

  1. Update Xcode to the latest version

  2. Make sure your build target deployment version is set to iOS 13.0

  3. Quit the applications Simulator and Xcode if they are open

  4. Using Finder, navigate to the folder which your version of Xcode is located (mine is in my Applications folder)

  5. Control + click on Xcode, and select 'Show Package Contents'

  6. Navigate to /Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime

  7. Control + click on 'iOS.simruntime', and select 'Show Package Contents'

  8. Navigate to /Contents/MacOS and verify you see a document named 'iOS 13.0'

  9. Exit out of the 'MacOS' folder back to the 'Contents' folder and Navigate to /Resources/RuntimeRoot/System/Library/Audio

  10. Copy the entire 'MIDI Drivers' folder

  11. Exit out of the 'Audio' folder and navigate all the way back to the 'RuntimeRoot' folder

  12. Navigate to /Library/Audio and you should see there is no folder called 'MIDI Drivers' here, only 'Plug-Ins' and 'Tunings'

  13. Paste the 'MIDI Drivers' folder you copied into this 'Audio' folder

  14. Close Finder, relaunch Xcode and try running your project again in the iOS 13 simulator

Now, Xcode should not complain about missing the MIDI Drivers, and your code should run without the EXE_BAD_ACCESS! I hope this helps, and please feel free to reach out to me if you have any more questions.

Laoighis answered 28/9, 2019 at 20:36 Comment(7)
This is amazing and it works. 1) How do you know this? 2) these instructions could possibly be simplified by using cmd-shift-G and going to the folders in question, like /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Audio etc. THANKS FOR THIS.Grantham
Thank you for confirming this works! I'm happy it solved the problem for everyone. First, I tried testing on my iPhone, and then I knew it was only a Simulator issue. So I dug around in the folders of Xcode for 3 days trying to figure out where the MIDI drivers for the Simulator were stored. I figured it out after reading through Apple's CoreMIDI framework. Sometimes Apple leaves useful comments in their code which can be more useful than the documentation. By reading what Apple stated, I found out that the Library folder on the device also needed to have the drivers.Laoighis
That’s bold, big up!Grantham
Also, I realize the instructions were long. I wanted to make sure I was specific so people wouldn't get lost, but I like your suggestion of using cmd-Shift-G. I completely forgot about doing that. You can also navigate through the directories in Terminal in one step, which can be useful for those who know how to use Terminal.Laoighis
I’m in favor of terminal, but glad for the answer and any edits in any caseGrantham
Me too terminal is very helpful. By the way, I thought I should let everyone know on this thread I just realized Apple is getting ready for MIDI 2.0. This makes sense why Xcode 11.1 and even 11.0 was having trouble with MIDI drivers because the CoreMIDI framework is most likely in intense development at the moment. I believe Apple patched the MIDI driver bug now, and I found a new file in the CoreMIDI framework called MIDICapabilityInquiry.h . I'm not sure if it's new or if Apple just added it back in. I didn't see it before, but apparently it was added in iOS 12.Laoighis
I assume Apple removed this file for the initial release of iOS 13. They must have been testing it to make sure it was compatible with iOS 13.Laoighis
G
2

This is just a simplification of the accepted answer, since I do this often. Assuming your Xcode is in /Applications/Xcode.app:

Copy MIDI Drivers from

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Audio

to

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Audio

and relaunch Xcode.

Note

So it's present in RuntimeRoot/System/Library/Audio and needs to be in RuntimeRoot/Library/Audio as well.

Grantham answered 10/11, 2019 at 17:35 Comment(0)
I
1

This should be resolved in the iOS 13.2 simulator included with Xcode 11.2; the root cause was exactly what Evan identified - files at the wrong path.

Iodic answered 12/10, 2019 at 4:3 Comment(4)
I just ran into this problem using iOS 13.2 sim and Xcode 11.2. So I don't think it's fixed.Sextain
Are you certain? I've tested this myself and it worked after the upgrade.Iodic
Yep. Might be because I have both the beta and the stable versions of Xcode installed. I ran the steps in the answer and things worked after that.Sextain
This should be a comment on the accepted answer (unless you don't have enough points to comment). Thanks.Grantham

© 2022 - 2024 — McMap. All rights reserved.