I have been having an issue with specifying a path for my source files in the Library I'm working on. I have most of the files under the Sources directory but the library is a mix of Objective-C and Swift code.
Here is the error that I get when running "swift build" error: the package does not contain a buildable target
Could someone advise me on a possible way to approach this or fix the error?
The source code for the package is mostly Swift with a few files in Objective-C. The folder structure is
Sources
|_ _ Models
|_ _ Objc
|_ _ Subclasses
|_ _ Support Files
|_ _ UI
|_ _ Utils
I wanted to give a bit more context. I tried to use a framework called Wormholy in a project by using it thru SPM via Xcode. I received the following error and I figured I'd try to fix it and submit a PR to the original developer.
After doing a bit of research, I tried to update the path for the source files in the manifest file but I came to the error I mentioned in my original post.
Here is my Manifest file:
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Wormholy",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Wormholy",
targets: ["Wormholy"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Wormholy",
dependencies: [],
path: "Sources"),
.testTarget(
name: "WormholyTests",
dependencies: ["Wormholy"]),
]
)
Here is the original error I receive that prompted me to reach out for help here
➜ Wormholy git:(develop) swift build
'Wormholy' /Users/Vadym/Developer/projects/Wormholy: warning: Ignoring declared target(s) 'Wormholy, WormholyTests' in the system package
error: the package does not contain a buildable target
However, to get the Objective C one to build, I also needed to comment out an import that does not exist, and the two lines that use it:
With those changes both targets can be successfully imported by a client.
I assume the developer is accustomed to the missing header being generated automatically. It will have to be checked in to use it with SwiftPM.
Lastly, just because the targets can be imported does not necessarily mean they will work as intended. I see several interface builder files in there. None of those will be available to Wormholy in SwiftPM builds.