I am happy to say that the package manifest caching feature has landed and is available to try using trunk development snapshots. This should provide a significant speedup in almost all SwiftPM operations.
Most SwiftPM commands operate on a "PackageGraph" object which requires loading the manifest file of a package and its dependencies. SwiftPM loads manifest files by invoking the Swift compiler which is an expensive operation. As you can imagine, the problem becomes worse as the number of dependencies increase in a package.
To solve this, SwiftPM will now cache the loaded manifests for effectively all operations except dependency resolution. This provides great performance improvements during iterative development. Commands like swift build, swift test, swift package edit, swift package generate-xcodeproj should start significantly faster once the cache is created. For e.g., time spent to load all manifests of Vapor reduces from 3.7s to 64ms!
If you're interested in trying this feature, please install the latest trunk snapshot. This feature is enabled by default. If needed, it can be disabled by passing
--disable-package-manifest-caching flag. If you encounter any bug or have any other feedback, please let me know!