What changed in SPM with Swift 5.2 as far as target dependencies from external packages?

When using Swift 5.2 I have noticed that SPM wants me to declare more dependencies from external packages using the specific .product syntax: i.e.

.target(
    name: "Example", 
    dependencies: [.product(name: "MyPackage", package: "Foo")])

In previous versions, I was able to merely declare the name of the product as a string:

.target(
    name: "Example", 
    dependencies: ["Foo"])

It seems as if this implicit behavior still works if the product name is the same as the package name, but it fails if it is different.

Is there any documentation or rules on exactly when it's required to explicitly name a product, vs. using the "myName" mode to implicitly specify a product?

As you figured out, the short form is now only available when the product and package names are the same.

You can read the details in SE‐0226.

2 Likes