Segfault when switching to a custom keyboard layout from Touch Bar I am using a custom keyboard layout, created by Ukelele. It was serving me well for years, until I started to use it on a MacBook Pro with Touch Bar. I added the "Change Input Language" button to the Touch Bar's Control Strip and whenever I press it, the language is switched. It worked fine for weeks, but suddenly it is just not switching from the Touch Bar. But it does switch from the top menu bar and keyboard.

Now some technical details. I've tried to use both a .keylayout file as well as bundle file. I've tried to install it both in /Library/... and in ~/Library/.... When the problem appears, it's not easy to recover it, even with reboots. Removing/adding my custom layout again doesn't work most of the time. The Touch Bar does switch using built-in languages.

I've contacted the developer of Ukelele, but he couldn't test it due to not having a MacBook Pro with Touch Bar and had no clue.

So I looked into logs and found a Touch Bar crash:

Jul 23 21:45:17 xxxx com.apple.DFRSystemExtra.InputMenu[763]: objc[763]: Class TIMLog is implemented in both /System/Library/CoreServices/Menu Extras/TextInput.menu/Contents/SharedFrameworks/TextInputUI.framework/Versions/A/TextInputUI (0x102c88858) and /System/Library/CoreServices/ControlStrip.app/Contents/XPCServices/com.apple.DFRSystemExtra.InputMenu.xpc/Contents/MacOS/com.apple.DFRSystemExtra.InputMenu (0x102c64958). One of the two will be used. Which one is undefined.
Jul 23 21:45:18 xxxx com.apple.xpc.launchd[1] (com.apple.DFRSystemExtra.InputMenu[763]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]


I noticed one difference - built in languages show a 2 letter language name on the Touch Bar button, while my custom layout shows an icon. I haven't found a way in Ukelele to make my custom layout show a 2 letter language abbreviation—maybe someone can suggest a way that I can try. So my guess is that it happens due to the custom layout icon, but it was copied from a built-in layout.
I'm using the Bépo layout and I was experiencing the same issue.

I recreated the .icns file using the iconutil command. I just provided the 16x16, 16x16@2x and 32x32 icons.


Create a folder named &lt;your_layout&gt;.iconset
Put your icons inside. They MUST be named icon_16x16.png, icon_16x16@2x.png, icon_32x32.png, …, icon_512x512@2x.png.
Run the command iconutil -c icns &lt;your_layout&gt;.iconset
Copy the resulting .icns file to your keyboard layout.


Since then I had no more TouchBar crash on layout switch.