Ras*_*sto 9 git xcode github swift-package-manager xcode11
我的库FlexColorPicker最近采用了 SPM 支持。它有效,但我不喜欢当通过 XCode 添加 FlexColorPicker 包时(文件?Swift 包?添加包依赖...?选择目标?输入https://github.com/RastislavMirek/FlexColorPicker?确认)一些不需要的文件被下载,例如FlexColorPicker.podspec和整个GifsAndScreenshots文件夹。
有没有办法防止下载这些不必要的文件?
Package.swift通过将文件添加到要排除的文件夹中,可以从包中排除文件夹,其中包含以下内容:
// swift-tools-version:5.5
import PackageDescription
let package = Package()
Run Code Online (Sandbox Code Playgroud)
这将不再使其在 XCode 导航器中可见。
您可以使用文件中exclude目标上的参数执行此Package.swift操作。它接受一组路径(相对于目标根)。
从文档:
/// Create a library or executable target.
///
/// A target can either contain Swift or C-family source files. You cannot
/// mix Swift and C-family source files within a target. A target is
/// considered to be an executable target if there is a `main.swift`,
/// `main.m`, `main.c` or `main.cpp` file in the target's directory. All
/// other targets are considered to be library targets.
///
/// - Parameters:
/// - name: The name of the target.
/// - dependencies: The dependencies of the target. These can either be other targets in the package or products from package dependencies.
/// - path: The custom path for the target. By default, targets will be looked up in the <package-root>/Sources/<target-name> directory.
/// Do not escape the package root, i.e. values like "../Foo" or "/Foo" are invalid.
/// - exclude: A list of paths to exclude from being considered source files. This path is relative to the target's directory.
/// - sources: An explicit list of source files.
/// - publicHeadersPath: The directory containing public headers of a C-family family library target.
/// - cSettings: The C settings for this target.
/// - cxxSettings: The C++ settings for this target.
/// - swiftSettings: The Swift settings for this target.
/// - linkerSettings: The linker settings for this target.
...
Run Code Online (Sandbox Code Playgroud)
在 Package.swift 文件中使用它看起来像这样:
...
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: "MyApp",
dependencies: [],
exclude: ["example.swift"]
),
...
Run Code Online (Sandbox Code Playgroud)
此外,developer.apple.com 有一些目标文档 -> exclude 参数
目前这是不可能的。SwiftPM 会克隆 git 存储库,因此它也会获取其中的任何文件。
我知道 git 可以从存储库克隆特定路径,但我不确定其限制。为了使用 SwiftPM 支持此类功能,需要有一个 Swift Evolution 提案。
| 归档时间: |
|
| 查看次数: |
2402 次 |
| 最近记录: |