Type 'Bundle' has no member “module”

半世苍凉 提交于 2020-12-11 00:57:48

问题


I have tried solutions in this question: Generating resource_bundle_accessor, Type 'Bundle' has no member 'module' however it still does not work.

I am trying to access a simple JSON file in my unit tests. Here is my Package.swift:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyLibrary",
    platforms: [.iOS("11.0"), .macOS(SupportedPlatform.MacOSVersion.v10_12)],
    products: [
        .library(name: "MyLibrary", targets: ["MyLibrary"])], dependencies: [],
    targets: [
        .target(name: "MyLibrary", dependencies: []), .testTarget(name: "MyLibraryTests", resources: [.process("recommendations.json"], dependencies: ["MyLibrary"]),
    ]
)
  • I am using swift-tools 5.3
  • I have added the recommendations.json to my package.swift.

I have closed and re-opened Xcode 5 times, yet still it does not create the Bundle.module extension. Here is my file structure:

How can I access my JSON file in my unit tests?

来源:https://stackoverflow.com/questions/64400676/type-bundle-has-no-member-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!