Swift Package Manager got a New Feature! Yea! Hurray! 🙌👯🍾🎉🐣🎉
But why we needed it? Let's see ...
Let's have a look on this folder structure
Package ├── LibA │ └── A.swift ├── LibB │ └── B.swift ├── Tools │ └── Tools.swift
Now we run
swift-build and get the follow result:
.build ├── LibA.a ├── LibB.a ├── Tools.a
So, the problem here is that I don't want to generate a target for a
Tools folder. I want to exclude it. Let's do that, it've very easy.
Package.swift file and declare exclude folders for your package.
import PackageDescription let package = Package( exclude: ["Tools"] )
That's it!🎉 Now just clean cached
.build folder and build the package again. Not it creates only 2 targets
Some rules to remember:
- You can exclude many folders.
- Also you can specify path to a nested folder.
- The names are case-sensitive.
"Tools" != "tools")
import PackageDescription let package = Package( exclude: ["Tools", "someOther", "Lib/code/Old"] )
The paths specified in the
exclude are relative to the Root folder of the package. This means that the example above would exclude these folders:
Package ├── Tools ├── someOther ├── Lib │ └── code │ └── Old
To use that feature you need use latest version of a
swift-build from master branch.
- Clone the repo,
swift-buildtool by running
- Run it -
./swift-build --chdir PackagePathToBuild
./swift-build --chdir /Users/kostiantyn/HelloSPM