2

我有一个带有两个目标(AB)的框架,文件结构如下:

FooFramework
|__ A
     |__ Foo.swift
     |__ Bar.swift
     |__ Foobar.swift
|__ B
     |__ Barfoo.swift

B基本上有一个A's 源的子集(其中B设置为目标),例如B只使用Foo.swiftand Bar.swift,但不使用Foobar.swift.

现在我有一个需要框架AB(在单独的目标中)的应用程序。

在这一点上,我不确定如何设置Package.swift文件以使此设置正常工作。每当我打开Package.swiftinXcode并尝试构建框架B时,编译器都会抱怨 in 缺少类型Barfoo.swift,因为它们包含在Bar.swift.

这就是我设置Package.swift文件的方式:

// swift-tools-version:5.3

import PackageDescription

let package = Package(
    name: "Framework",
    platforms: [
        .iOS(.v11),
        .macOS(.v10_15)
    ],
    products: [
        .library(
            name: "A",
            targets: ["A"]),
        .library(
            name: "B",
            targets: ["B"]),
    ],
    dependencies: [
        .package(name: "Dependency", url: "https://github.com/...", .exact("1.0.0"))
    ],
    targets: [
        .target(
            name: "A",
            dependencies: [
                "Dependency",
            ],
            path: "A",
            exclude: [
                "Info.plist",
            ],
            resources: [
                .process("fonts"),
            ]
        ),
        .target(
            name: "B",
            dependencies: ["A"],
            path: "B",
            exclude: [
                "Info.plist",
            ],
            resources: [
                .process("../A/fonts"),
            ]),
        .testTarget(
            name: "ATests",
            dependencies: ["A"],
            path: "ATests",
            exclude: [
                "Info.plist"
            ]
        )
    ]
)

相关来源,但不幸的是没有帮助:

4

0 回答 0