Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

ld: symbol(s) not found with package using Bundle.module #139

Open
kientux opened this issue Apr 25, 2022 · 3 comments
Open

ld: symbol(s) not found with package using Bundle.module #139

kientux opened this issue Apr 25, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@kientux
Copy link

kientux commented Apr 25, 2022

For example, when integrate Siren package, which use Bundle.module here, the linker step will produce error:

Undefined symbols for architecture arm64:
  "static (extension in Siren):__C.NSBundle.module : __C.NSBundle", referenced from:
      function signature specialization <Arg[1] = Dead> of static (extension in Siren):__C.NSBundle.(sirenForcedBundlePath in _9C775CF4CEC7A5F21E625F58C71BDF22)(forceLanguageLocalization: Siren.Localization.Language) -> Swift.String? in libSiren_a_file.a(BundleExtension.swift.o)
      function signature specialization <Arg[2] = Dead> of static (extension in Siren):__C.NSBundle.localizedString(forKey: Swift.String, andForceLocalization: Siren.Localization.Language?) -> Swift.String in libSiren_a_file.a(BundleExtension.swift.o)
  "one-time initialization function for module", referenced from:
      function signature specialization <Arg[1] = Dead> of static (extension in Siren):__C.NSBundle.(sirenForcedBundlePath in _9C775CF4CEC7A5F21E625F58C71BDF22)(forceLanguageLocalization: Siren.Localization.Language) -> Swift.String? in libSiren_a_file.a(BundleExtension.swift.o)
      function signature specialization <Arg[2] = Dead> of static (extension in Siren):__C.NSBundle.localizedString(forKey: Swift.String, andForceLocalization: Siren.Localization.Language?) -> Swift.String in libSiren_a_file.a(BundleExtension.swift.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When integrate 2 of my Swift packages which both use Bundle.module, it produces the same error. I have little knowledge about Bazel and just trying to migrate to using it, so I can only report this much information. Please tell me if you need more info.

WORKSPACE:

spm_repositories(
    name = "swift_pkgs",
    dependencies = [
        spm_pkg(
            name = "Siren",
            url = "https://github.com/ArtSabintsev/Siren",
            exact_version = "5.7.1",
            products = ["Siren"],
        ),
    ],
    platforms = [
        ".iOS(.v12)",
        ".macOS(.v10_14)"
    ]
)

BUILD:

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

swift_library(
    name = "App_Classes",
    srcs = glob([
        "*.swift",
    ]),
    data = [
    ],
    deps = [
        "@swift_pkgs//Siren",
    ],
)

ios_application(
    name = "ios_app",
    bundle_id = "io.github.kientux.bazel",
    families = ["iphone"],
    infoplists = ["Info.plist"],
    minimum_os_version = "12.0",
    visibility = ["//visibility:public"],
    deps = [
        ":App_Classes",
    ],
)

@cgrindel
Copy link
Owner

Thanks for reporting the issue. I hope to have some time to investigate later this week.

@cgrindel cgrindel added the bug Something isn't working label May 5, 2022
@Antonito
Copy link

Hello,

I am facing the same issue with another package that makes use of Bundle.module.
I worked around this scenario with my own SPM packages by adding:

import class Foundation.Bundle

#if !SWIFT_PACKAGE
extension Foundation.Bundle {
  fileprivate final class Token {}

  static var module: Bundle = .init(for: Token.self)
}
#endif

Has there been any progress on this issue?
If not, is there any workaround / solution for external dependencies ?

Thank you!

@cgrindel
Copy link
Owner

Unfortunately, no. I have been buried with some other projects. I am open to contributions, if you have thoughts on how to tackle this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants