That is basically what swiftenv does. You can put a .swift-version file in any directory to change the local swift version used in subdirectories of that directory and then there is also a global swift version used when there is no .swift-version file that sets the local version.
4 Likes