ios - 没有这样的模块 Swift 包

标签 ios swift xcode11 swift-package-manager

我的应用程序中有 2 个软件包,

  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 依赖于 MSExtension,用于访问 Button 和 Label 的一些常见功能,

因此,我已将 MSExtension 导入到 CustomUIPackageApp 中。 如果我为模拟器构建并运行它按预期工作,我就能够构建并执行该应用程序。

我能够为模拟器以及通用 iOS 设备构建项目,但是当我尝试存档项目时,出现错误

No such module MSExtension

错误出现在导入 MSExpension 包的 CusomUIPackage

importing a package inside other package

还有其他更好的方法可以实现这一目标吗?如有任何帮助,我们将不胜感激。

最佳答案

阅读有关 swift 包管理器并添加来自 link 的依赖项后

我通过添加依赖项列表及其路径来更改 Package.swift。我能够存档该应用程序。

之前,未指定 swift 包管理器的依赖项。

 
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"]),
    ]
)


之后

 
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"]),
    ]
)


关于ios - 没有这样的模块 Swift 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63638226/

相关文章:

swift - 如何使用 applicationWillResignActive 调用 View Controller 的函数

ios - 我怎样才能重新启动 SKScene?

ios - 从 Swift 中的另一个类刷新 UITableView

swift - 更改 LLDB 中的 Int 变量值

swiftui - CoreData 和 FetchRequest,ForEach 和 "Cannot invoke initializer"问题

ios - 从 Xcode 11.1 升级到 Xcode 11.2 后,应用程序因 _UITextLayoutView 崩溃

ios - UIImage 遍历像素非常低效?

iphone - 在自定义 UIBarButtonItem 周围设置边框

iOS 拆分键盘搞乱了 cordova webview

ios - AFNetworking 请求 API iOS