Luca
Luca

Reputation: 974

SPM package can't find import SwiftUI

I'm using a Swift Package Manager packet made by myself (Here is the Github Link) in my project, I tested the package and it does work correctly and it did for some days but when I tried to archive the app to publish it to TestFlight it started showing these error that doesn't make any sense to me

enter image description here

I have already

My Project

Upvotes: 1

Views: 940

Answers (1)

Luca
Luca

Reputation: 974

Turned out I had to specify an iOS, TvOS, watchOS and macOS versions which supports SwiftUI, in my case I used primarily the newest version for every platform because my library needs that but for SwiftUI the earliest supported version is iOS13

let package = Package(
    name: "SwiftUISnackbar",
    platforms: [
            .macOS(.v11),
            .iOS(.v14),
            .tvOS(.v14),
            .watchOS(.v7)
        ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "SwiftUISnackbar",
            targets: ["SwiftUISnackbar"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.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: "SwiftUISnackbar",
            dependencies: []),
        .testTarget(
            name: "SwiftUISnackbarTests",
            dependencies: ["SwiftUISnackbar"]),
    ]
)

Upvotes: 1

Related Questions