# Improving manifest loading performance for declarative package manifests

**URL:** <https://forums.swift.org/t/improving-manifest-loading-performance-for-declarative-package-manifests/85994>\
**Category:** Package Manager\
**Created:** [April 13, 2026, 5:21pm UTC](https://forums.swift.org/t/improving-manifest-loading-performance-for-declarative-package-manifests/85994 "2026-04-13T17:21:05Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![Geordie\_J](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/geordie_j/32/839_2.png) [@Geordie\_J](https://forums.swift.org/u/Geordie_J)\
**Post date:** [April 28, 2026, 11:06am UTC](https://forums.swift.org/t/improving-manifest-loading-performance-for-declarative-package-manifests/85994/41 "2026-04-28T11:06:49Z")

</div>

I also don’t love yaml but it‘d also be fine IMO. Personally I’m fine with the original direction suggested in the OP

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [May 11, 2026, 1:03am UTC](https://forums.swift.org/t/improving-manifest-loading-performance-for-declarative-package-manifests/85994/42 "2026-05-11T01:03:54Z")

</div>

Thanks for working on this, interesting approach.

> [@Douglas\_Gregor](#):
>
> We could also handle simple mutation patterns that aren't really declarative, but are nonetheless easy to model. For example, [`swift-argument-parser`](https://github.com/apple/swift-argument-parser/blob/main/Package.swift) adds some targets using `append(contentsOf:)` :
> 
> ```swift
> #if os(macOS)
> package.targets.append(contentsOf: [
> // Examples
> .executableTarget(
> name: "count-lines",
> dependencies: ["ArgumentParser"],
> path: "Examples/count-lines"),
> 
> // Tools
> .executableTarget(
> name: "changelog-authors",
> dependencies: ["ArgumentParser"],
> path: "Tools/changelog-authors"),
> ])
> #endif
> 
> ```
> 
> The parsing manifest loader already handles the `#if` using the [`SwiftIfConfig` library](https://swiftpackageindex.com/swiftlang/swift-syntax/603.0.0/documentation/swiftifconfig). However, it could recognize the `append(contentsOf:)` call to add these new targets.

This is a hack for the fact that the manifest format currently does not support building these executables only for certain platforms, a hack that only works when natively compiling for desktop platforms and breaks when cross-compiling, eg from macOS to Android. It would be great to fix this properly in the manifest format instead, as @Geordie_J also refers to later:

> [@Geordie\_J](#):
>
> What we _will_ need however is better handling of "don't download these external dependencies at all if they're unused in the targets being built for the current target platform", and "don't even think about producing this `Product` unless you're building for a certain platform", and the like. These are the only reasons we have conditional non-declarative code in our manifests today.

Another way to slim down manifests is to rely more on "convention over configuration", as [ruby on rails has been successful doing](https://github.com/vickyonit/rails-coc). While this can sometimes make packages more difficult to explore, as it would rely on everybody knowing the conventions, a way to remedy that would be a SwiftPM command to dump the package structure in some readable format, with perhaps a convention to always do so for read-only consumption.

Regarding adding other declarative formats, a way to do this sanely would be to have SwiftPM be able to generate swift/JSON/pkl/yaml/toml/name-your-format from the in-memory package manifest, then let contributors add support for their favorite format to SwiftPM, provided it parsed to the same in-memory manifest without requiring new features. Then when their package is built, SwiftPM would dump the same declarative format for all their dependencies, eg if they chose toml for their package, it would dump a toml file for each dependency in that package's source repo, translated from its Package.swift or Package.yaml.

I don't know if this would be worth the effort, but it would let the various format proponents have their preferred format.

[Previous page](https://forums.swift.org/t/improving-manifest-loading-performance-for-declarative-package-manifests/85994.md?page=2)
