diff --git a/mobile/bazel/swift_static_framework.bzl b/mobile/bazel/swift_static_framework.bzl index 8a002023517e..6f881457c3db 100644 --- a/mobile/bazel/swift_static_framework.bzl +++ b/mobile/bazel/swift_static_framework.bzl @@ -52,10 +52,17 @@ def _swift_static_framework_impl(ctx): # We can potentially simplify this if this change lands upstream: # https://github.com/bazelbuild/rules_swift/issues/291 - objc_headers = archive[apple_common.Objc].header.to_list() - objc_header = objc_headers[-1] - if objc_header: - zip_args.append(_zip_header_arg(module_name, objc_header)) + objc_headers = [ + header + for header in archive[apple_common.Objc].header.to_list() + if header.path.endswith("-Swift.h") + ] + + if len(objc_headers) == 1: + zip_args.append(_zip_header_arg(module_name, objc_headers[0])) + else: + header_names = [header.basename for header in objc_headers] + fail("Expected exactly 1 '-Swift.h' header, got {}".format(", ".join(header_names))) swiftdoc = swift_info.direct_swiftdocs[0] swiftmodule = swift_info.direct_swiftmodules[0]