Keyboard layout keeps reverting since upgrade to High Sierra
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_&lt;your-layout-name&gt; dict. Here's an example of the Info.plist from the layout I'm using:

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


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 &lt;something&gt;.lproj into &lt;language&gt;_&lt;REGION&gt;.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.