为什么使用Bundle.Module时找不到Swift软件包的捆绑包?

发布于 2025-01-27 14:56:36 字数 631 浏览 2 评论 0原文

我正在构建一个Swift软件包库,其中包含/swift-spk/sources/spk/resources/names.txt的文本资源。该资源被复制到目标中:

.target(
    name: "SPK",
    dependencies: [],
    resources: [
        .copy("Resources/names.txt")
]),

... ... bundle.module访问者被生成,我在Swift软件包中使用它在私有函数中(bundle.bundle.module call。 Swift软件包)。我在操场文件中运行代码,并且运行时失败了错误消息:

SPK/resource_bundle_accessor.swift:27: Fatal error: unable to find bundle named swift-spk_SPK

我正在遵循我在教程中找到的指南以及去年的类似问题,因此我很好奇资源加载是否有任何更改。

预先感谢您的任何支持

I'm building a Swift Package library that contains a text resource inside /swift-spk/Sources/SPK/Resources/names.txt. The resource is being copied into the target as:

.target(
    name: "SPK",
    dependencies: [],
    resources: [
        .copy("Resources/names.txt")
]),

... The Bundle.module accessor is generated and I use it in a private function within the Swift Package (the Bundle.module call is performed from within the Swift Package). I run the code within a Playground file and the runtime fails with an error message:

SPK/resource_bundle_accessor.swift:27: Fatal error: unable to find bundle named swift-spk_SPK

I'm following the guidelines I found on tutorials and similar questions from last year here so I'm curious if there have been any changes to the resource loading.

Thanks in advance for any support ????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文