I have created one swift package manager. In that i have to add third party package
https://github.com/danielgindi/Charts. I have added that package as dependancy in Package.swift file. It has been added and showing under package dependancies. But when i try to use that package, it is giving me error No such module ‘DGCharts’. What could be the issue here?
Package file
// 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()
}
In above it is giving error No such module ‘DGCharts’
2
Answers
You need to add it as a dependency to your target as well
You need to add the packaged dependency in the target’s dependencies list before you can use it.
From: https://developer.apple.com/documentation/packagedescription/package