For example, when I use the Messages app in which I use one keyboard, and in Xcode, I use only English keyboard. Can macOS switch my keyboard to English when I make the Xcode window active?
Follow these steps to changing your keyboard language dynamically:
I have developed a app for this functionality.
It will help you to setting default input source for almost every app. By using it, when your app become active, the input source will be automatically changed to the default input source which you setted in GhostSKB.