def METHOD_NAME(ctx):
    """Implementation for metal_library Skylark rule."""
    # A unique path for rule's outputs.
    objs_outputs_path = "{}.objs/".format(ctx.label.name)
    output_objs = []
    for src in ctx.files.srcs:
        basename = src.basename
        obj = ctx.actions.declare_file(objs_outputs_path + basename + ".air")
        output_objs.append(obj)
        diagnostics = ctx.actions.declare_file(objs_outputs_path + basename + ".dia")
        deps_dump = ctx.actions.declare_file(objs_outputs_path + basename + ".dat")
        args = (["metal"] +
                _metal_compiler_args(ctx, src, obj, ctx.attr.minimum_os_version, ctx.attr.copts, diagnostics, deps_dump))
        apple_support.run(
            ctx,
            xcode_path_resolve_level = apple_support.xcode_path_resolve_level.args,
            inputs = _metal_compiler_inputs(ctx.files.srcs, ctx.files.hdrs, ctx.attr.deps),
            outputs = [obj, diagnostics, deps_dump],
            mnemonic = "MetalCompile",
            executable = "/usr/bin/xcrun",
            arguments = args,
            use_default_shell_env = False,
            progress_message = ("Compiling Metal shader %s" %
                                (basename)),
        )
    output_lib = ctx.actions.declare_file(ctx.label.name + ".metallib")
    args = [
        "metallib",
        "-split-module",
        "-o",
        output_lib.path,
    ] + [x.path for x in output_objs]
    apple_support.run(
        ctx,
        xcode_path_resolve_level = apple_support.xcode_path_resolve_level.args,
        inputs = output_objs,
        outputs = (output_lib,),
        mnemonic = "MetalLink",
        executable = "/usr/bin/xcrun",
        arguments = args,
        progress_message = (
            "Linking Metal library %s" % ctx.label.name
        ),
    )
    objc_provider = apple_common.new_objc_provider(
        providers = [x[apple_common.Objc] for x in ctx.attr.deps if apple_common.Objc in x],
    )
    cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep]
    if ctx.files.hdrs:
        cc_infos.append(
            CcInfo(
                compilation_context = cc_common.create_compilation_context(
                    headers = depset([f for f in ctx.files.hdrs]),
                ),
            ),
        )
    return [
        DefaultInfo(
            files = depset([output_lib]),
        ),
        objc_provider,
        cc_common.merge_cc_infos(cc_infos = cc_infos),
        # Return the provider for the new bundling logic of rules_apple.
        resources.bucketize_typed([output_lib], "unprocessed"),
    ]