ld: symbol(s) not found with package using `Bundle.module`
Opened this issue · 3 comments
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",
],
)
Thanks for reporting the issue. I hope to have some time to investigate later this week.
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!
Unfortunately, no. I have been buried with some other projects. I am open to contributions, if you have thoughts on how to tackle this.