Swift Dependency Troubleshooting

If you’re trying to add a dependency to a Swift library, the Package.swift file may have a dependencies section that resembles the line below.

dependencies: ["FeedKit", “SQLite”]

At the time of writing, the above line fails with the error below because the product and library names are different.

dependency 'SQLite' in target ‘…’ requires explicit declaration; reference the package in the target dependency with '.product(name: "SQLite", package: "SQLite.swift")'

The error message doesn’t tell you where to add the .product entry. After a bit of tinkering, I figured out how to get rid of this error message.

Replace the SQLite entry in the dependencies array with the .product declaration, e.g.

dependencies: ["FeedKit",
               .product(name: "SQLite", package: "SQLite.swift")])

No Comments Yet