# Why does breaking up SwiftPM targets list cause typechecking to fall off a cliff?

**URL:** <https://forums.swift.org/t/why-does-breaking-up-swiftpm-targets-list-cause-typechecking-to-fall-off-a-cliff/71295>\
**Category:** Package Manager\
**Created:** [April 16, 2024, 10:14pm UTC](https://forums.swift.org/t/why-does-breaking-up-swiftpm-targets-list-cause-typechecking-to-fall-off-a-cliff/71295 "2024-04-16T22:14:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [April 16, 2024, 10:14pm UTC](https://forums.swift.org/t/why-does-breaking-up-swiftpm-targets-list-cause-typechecking-to-fall-off-a-cliff/71295/1 "2024-04-16T22:14:57Z")

</div>

i have a package manifest with a lot (\>100) targets that was basically impossible to navigate. so i wanted to break it up into collapsible sections like this:

```swift
var a:[Target]
{
    [
        // targets ...
    ]
}
var b:[Target]
{
    [
        // targets ...
    ]
}
var c:[Target]
{
    [
        // targets ...
    ]
}

... 
        .package(url: "https://github.com/apple/swift-system", .upToNextMinor(
            from: "1.2.1")),
        .package(url: "https://github.com/apple/swift-syntax",
            exact: "510.0.1"),
    ],
    targets: a + b + c)

```

for some reason, typechecking degrades non-linearly when i have more than two lists of targets, to the point where a simple `swift package dump-package` command takes many minutes to complete.

what is going on here? is there a better way to improve manifest navigability?

---

<div class="post-metadata">

**Author:** ![mayoff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mayoff/32/613_2.png) [@mayoff](https://forums.swift.org/u/mayoff)\
**Post date:** [April 17, 2024, 1:42am UTC](https://forums.swift.org/t/why-does-breaking-up-swiftpm-targets-list-cause-typechecking-to-fall-off-a-cliff/71295/2 "2024-04-17T01:42:32Z")

</div>

You can try adding your targets to your `Package` incrementally, like this:

```swift
let package = Package(…)

package.targets += a
package.targets += b
package.targets += c

```

Note that `Package` is a `class`, not a `struct`, so you don’t need to declare it `var`.

---

<div class="post-metadata">

**Author:** ![George](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/george/32/37757_2.png) [@George](https://forums.swift.org/u/George)\
**Post date:** [April 17, 2024, 3:15am UTC](https://forums.swift.org/t/why-does-breaking-up-swiftpm-targets-list-cause-typechecking-to-fall-off-a-cliff/71295/3 "2024-04-17T03:15:40Z")

</div>

My guess is that type inference of the array in the computed property is being accidentally-exponential.

@mayoff's suggestion should work, or you can try `let a: [Target] = []`. Unfortunately, the heuristics used to make type-checking literals not-slow are somewhat mysterious to me.
