Keyboard layout keeps reverting since upgrade to High Sierra

I had the same problem. My Custom keyboard was located in /Library/Keyboard Layouts. I heard that there are some file rights issues when using Ukulele - so I moved my custom keyboard to ~/Library/Keyboard Layout:

cd ~/"Libaray/Keyboard Layouts"
mv "/Library/Keyboard Layouts"/*

Also, I changed file owner, group and some rights for files at that location:

sudo chown <your username> *
sudo chgrp staff *
sudo chmod u+rwx *

Then, remove your custom keyboard from System Preferences, reboot, add again and reboot again.


I had the exact same problem: a custom keyboard layout that had worked just fine on macOS 10.12 Sierra suddenly refused to work with default applications and applications installed from App Store after updating to macOS 10.13 High Sierra. OS would always revert back to default keyboard layout of my region (Finnish). This got me thinking and I managed to fix the layout I use so that it now works with all apps, not just those installed from homebrew.

The trick is to modify your custom layout so that it is set to your current region. You can do this by either modifying the bundle manually or using Ukelele.

1. Editing the layout with Ukelele

Download and install Ukelele from for example homebrew. When you open the app open your custom layout from file or if you have it currently active you can create new bundle based on it by choosing ‘File’ → ‘New from current input source’. After you have it open you must set correct language (and possibly region) for it from ‘Language…’ settings found from ‘Keyboard Layouts’ tab. The language doesn't have to match the language of the OS and I don't know if the region has anything to do with this issue (Ukelele says it's optional) but setting it to your region can't hurt.

After setting the language from the ‘Keyboard Layouts’ tab you need to set the localisation from ‘Localisations’ tab. If there is already a locale line in the list you can edit it by double clicking it and setting the language (still doesn't have to match the language of the OS), if not you can add a new one with the button with a ‘+’ sign on it. Setting the region is optional here as well but better safe than sorry. After this you can save the bundle and jump to installing and enabling your layout.

2. Editing the layout manually

Keyboard layout bundles are actually just directories with certain structure, so you can also edit them manually from command line. What do you need to do is to cd into the Your.bundle/Contents and edit Info.plist by adding KLInfo_<your-layout-name> dict. Here's an example of the Info.plist from the layout I'm using:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleIdentifier</key>
        <string>com.apple.keyboardlayout.arkkudvorak</string>
        <key>CFBundleName</key>
        <string>ArkkuDvorak</string>
        <key>CFBundleVersion</key>
        <string>1.0</string>
        <key>KLInfo_ArkkuDvorak</key>
        <dict>
                <key>TISInputSourceID</key>
                <string>com.apple.keyboardlayout.arkkudvorak.arkkudvorak</string>
                <key>TISIntendedLanguage</key>
                <string>fi-FI</string>
        </dict>
</dict>
</plist>

The main thing here is to include your language and region abbreviations as string value for TISIntendedLanguage. I guess TISInputSourceID can be anything as long as it's prefixed by CFBundleIdentifier.

After you've set the language and region you can save and close the Info.plist file. You still need to edit the directory struture a bit though. cd into Your.bundle/Contents/Resources and rename the <something>.lproj into <language>_<REGION>.lproj, in my case fi_FI.lproj. After you've done that you're done with the changes.

3. Installing and enabling your layout

After correcting the language, region and localisation settings and saving the bundle move it to /Library/Keyboard Layouts/ if you didn't edit it directly from there. Restart your computer, re-add the layout from ‘System ‘Preferences’ → ‘Keyboard’ → ‘Input Sources’ and it should now work with all apps.

This did it for me, let me know if it worked for you.

Disclaimer: I'm not the author of the ArkkuDvorak bundle, I just use it.


Not a new answer but a comment (need 50 rep points!) to issue raised by @Miikka.

Make sure to disable "Automatically switch to a document's input source". When you do that, my input source selection stayed with the intended one.