Generating resource_bundle_accessor, Type 'Bundle' has no member 'module'

前端 未结 3 922
死守一世寂寞
死守一世寂寞 2020-12-16 17:00

Some times Xcode can not determine the module parameter in the Bundle.

Type \'Bundle\' has no member \'module\'

My inve

相关标签:
3条回答
  • 2020-12-16 17:10

    Bundle.module will only be generated by SwiftPM if the resources in the Package.swift file is not empty and the specified resources actually exist.

    So there are two possible reasons why it might not work for you:

    1. You don't have any resources specified in Package.swift. Fix like this:
    .target(
        name: "MyLibrary",
        dependencies: [
            /* your dependencies */
        ],
        resources: [
            .copy("JsonData"),
            .process("Assets.xcassets"),
        ]
    ),
    
    1. The specified paths don't exist or are empty.

      Fix by checking that you've actually placed your resources inside the Sources/MyLibrary directory. A common mistake is to place them directly to Sources or to a different targets subfolder.

    0 讨论(0)
  • 2020-12-16 17:25

    SPM generates the resource_bundle_accessor only if the corresponding target contains resources as the argument like:

        .target(
            name: "ChenzookKit",
            dependencies: ["Apollo"],
            resources: [.process("Resources")] // <- `copy` or `process` deson't really matter 
        ),
    

    Also, note that it should be a valid resource path.

    AND❗️

    The project MUST actaully contains Resources inside the target's Directory!

    0 讨论(0)
  • 2020-12-16 17:25

    Okay I found a solution, so Swift actually generates the Bundle.module file

    0 讨论(0)
提交回复
热议问题