gpt4 book ai didi

xcode - 如何使用Swift Package Manager从 repo 中排除文件/文件夹?

转载 作者:行者123 更新时间:2023-12-03 16:17:32 26 4
gpt4 key购买 nike

我的图书馆FlexColorPicker最近采用了SPM支持。它有效,但我不喜欢通过XCode添加FlexColorPicker软件包时(文件→Swift软件包→添加软件包依赖项...→选择目标→输入https://github.com/RastislavMirek/FlexColorPicker→确认),例如下载了一些不需要的文件。 FlexColorPicker.podspec和整个GifsAndScreenshots文件夹。

有没有办法防止卸载此不必要的文件?

最佳答案

您可以通过在exclude文件中的目标上使用Package.swift参数来执行此操作。它接受路径数组(相对于目标根)。
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.
...
在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"]
),
...
另外,developer.apple.com也有一些 docs for the target -> exclude parameter

关于xcode - 如何使用Swift Package Manager从 repo 中排除文件/文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58321967/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com