我创建了一个Swift包管理器。在这一点上,我必须添加第三方软件包https://github.com/danielgindi/Charts。我已经在Package.swift文件中添加了该包作为依赖项。它已被添加并显示在包依赖项下。但当我尝试使用该软件包,它给我错误没有这样的模块'DGCharts'.有什么问题吗?
包文件
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "XYZFramework",
platforms: [
.iOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "XYZFramework",
targets: ["XYZFramework"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/danielgindi/Charts.git", .upToNextMajor(from: "5.0.0"))
],
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 this package depends on.
.target(
name: "XYZFramework",
dependencies: []
/*,
resources: [Resource.process("XYZFramework/Sources/XYZFramework/Resources/XYZFramework.xcassets")]*/),
.testTarget(
name: "XYZFrameworkTests",
dependencies: ["XYZFramework"]),
]
)
import SwiftUI
import DGCharts
struct SwiftUIView: View {
let chartView = PieChartView()
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
SwiftUIView()
}
在上面它是给错误没有这样的模块'DGCharts'
1条答案
按热度按时间sczxawaw1#
您需要在目标的依赖项列表中添加打包的依赖项,然后才能使用它。
有时,Xcode会要求你显式声明目标的依赖项。你可以通过使用product(name: String, package: String? = nil)来帮助Xcode做到这一点。
From:https://developer.apple.com/documentation/packagedescription/package