Subscribed unsubscribe Subscribe Subscribe

JPMartha's Pancake

This blog is the way to brush up my poor English.

#swiftlang How to Exclude Subdirectory with The Swift Package Manager 💣

Updated: 2016-03-26

👉 日本語: Swift Package Manager (SPM) の除外設定 - Qiita


I hadn't noticed how to exclude subdirectory, but it has mentioned in the documentation. 😭

Summary

To exclude some files and directories without Swift file from Package, it's necessary to declare that in the Manifest file.

Tests or any subdirectory can be excluded via Manifest file.


swift-package-manager/SourceLayouts.md at swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a · apple/swift-package-manager · GitHub

Package.swift — The Manifest File

For example, the APIHimotoKit package has the Documentation directory without Swift file. So, I declare the following in the Manifest File.

import PackageDescription

let package = Package(
    name: "APIHimotoKit",
    dependencies: [
        .Package(url: "https://github.com/JPMartha/APIKit.git",
            Version(2, 0, 0)),
        .Package(url: "https://github.com/JPMartha/Himotoki.git",
            Version(2, 0, 0))
    ],
    exclude: ["Documentation"]
)

No Declaration

An error has occured when building.

error: NoSources("/.../Documentation")

Supplementation

EARLY DAYS

The Swift Package Manager is still in early design and development. 🚧

We have discussed with it in the Swift.org community, so it might be changed in the future. 👷🏻

and so on.

Environment in this case

  • OS X 10.11.4
  • swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a

Dependency in this case

Addition

🚨 Please note, the following way might be gone. 😅

Fetch Pre-release version SR-1039 by kostiakoval · Pull Request #223 · apple/swift-package-manager · GitHub

It seems that the original APIKit and the original Himotoki have been released as the pre-release versions supporting the Swit Package Manager.

To specify the pre-release versions, set dependencies the following:

dependencies: [
    .Package(url: "https://github.com/ishkawa/APIKit.git",
        Version(2, 0, 0, prereleaseIdentifiers: ["beta", "2"])),
    .Package(url: "https://github.com/ikesyo/Himotoki.git",
        Version(2, 0, 0, prereleaseIdentifiers: ["beta", "2"]))
]