如何使用Swift Package Manager将文件/文件夹从repo中排除? 我的图书馆FlexColorPicker最近采用了SPM支持。它有效,但是当通过Xcode添加FlexcolorPicker软件包时,我不喜欢这样,下载了一些不需要的文件。例如,Flexcolorpi ...

问题描述 投票:0回答:2
和整个

GifsAndScreenshots文件夹。 有一种方法可以防止下载这些不必要的文件?

使用Xcode添加一个软件包:文件→Swift软件包→添加软件包依赖关系...→选择目标→输入
https://github.com/RastislavMirek/FlexColorPicker
→确认

您可以使用

exclude
文件中的目标上的

Package.swift
xcode git github xcode11 swift-package-manager
2个回答
15
投票

docs

/// 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.
...

在包装中使用它。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"] ), ...

,developer.apple.com有一些目标 - > dubl参数

    

可以通过在要排除的文件夹中添加一个文件,并使用这些内容来排除包装夹,从包装中排除文件夹:

Package.swift 这将不再使其在Xcode Navigator中可见。


7
投票
目前不可能。 SwiftPM执行git repo的克隆,因此它也将获得任何这些文件。

我知道git可以从仓库中克服特定的路径,但我不确定限制。为了支持SwiftPM的此类功能,需要提出快速进化提案。

	

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.