joy son
joy son

Reputation: 585

No such module Swift Package

I have 2 packages inside the app,

  1. MSExtension -> Contains some func related to the view controller, views, and labels, etc...

  2. CustomUIpackage -> Standard custom UI like Button, label, and Radio buttons

CustomUIPackage has a dependency on the MSExtension, for the purpose of accessing some common functionalities of Button and Label,

So I have imported MSExtension into the CustomUIPackage and App. If I build and Run for the simulator it is working as expected, I am able to build and execute the app.

I am able to build the project for simulator as well as generic iOS device But When I try to archive the project getting error as

No such module MSExtension

The error is in the CusomUIPackage where MSExpension package is imported

importing a package inside other package

Is there any other way Better way I can achieve this?. Any help is appreciated.

Upvotes: 2

Views: 3412

Answers (1)

joy son
joy son

Reputation: 585

After Reading about swift package manager and adding the dependency from link

I changed the Package.swift by adding the dependency list and its path. I was able to archive the app.

Before, Not specifying the dependency for the swift package manager.

 
import PackageDescription

let package = Package(
    name: "MSUIElements",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "MSUIElements",
            targets: ["MSUIElements"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        // No depency path added
    ],
    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 which this package depends on.
        .target(
            name: "MSUIElements",
            dependencies: []),      // dependcy name not mentioned
        .testTarget(
            name: "MSUIElementsTests",
            dependencies: ["MSUIElements"]),
    ]
)


After

 
import PackageDescription

let package = Package(
    name: "MSUIElements",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "MSUIElements",
            targets: ["MSUIElements"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    .package(path:"../MSExtension")
    ],
    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 which this package depends on.
        .target(
            name: "MSUIElements",
            dependencies: ["MSExtension"]),
        .testTarget(
            name: "MSUIElementsTests",
            dependencies: ["MSUIElements"]),
    ]
)


Upvotes: 2

Related Questions