Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Adding third party dependancy in swift package manager issues

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’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to add it as a dependency to your target as well

.target(
    name: "XYZFramework",
    dependencies: ["DGCharts"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading