bazelbuild / rules_apple

Bazel rules to build apps for Apple platforms.
Apache License 2.0
507 stars 260 forks source link

XCFramework for macOS #1475

Open yuriyhanysh opened 2 years ago

yuriyhanysh commented 2 years ago

Hello! Is there a way to create XCFramework for both iOS and macOS using apple_xcframework? minimum_deployment_os_versions and minimum_os_versions attributes don't seem to work. And ios attribute allows you to specify only ios architectures.

yuriyhanysh commented 2 years ago

OK, I see how I can implement this. I'll work on PR.

xiemotongye commented 6 months ago

Is there a follow-up? I'm now facing a same issue.

luispadron commented 6 months ago

I'd also like this so if anyone is already working on this let me know otherwise I'll likely spend some time to get this working for macOS

luispadron commented 3 months ago

Started looking into this a bit and I believe the issue might be in Bazel core, given:

apple_xcframework(
    name = "ios_and_macos_dynamic_xcframework",
    bundle_id = "com.google.example",
    extension_safe = True,
    infoplists = [
        "//test/starlark_tests/resources:Info.plist",
    ],
    ios = {
        "simulator": ["x86_64"],
        "device": ["arm64"],
    },
    minimum_os_versions = {
        "ios": common.min_os_ios.baseline,
        "macos": common.min_os_macos.baseline,
    },
    public_hdrs = [
        "//test/starlark_tests/resources:shared.h",
    ],
    tags = common.fixture_tags,
    deps = [":fmwk_lib"],
)

I get the following output when examining the split transition keys used here:

Error in fail: [("ios_arm64_device", <target //apple:default_cc_toolchain_forwarder>), ("ios_x86_64_simulator", <target //apple:default_cc_toolchain_forwarder>)]
luispadron commented 3 months ago

I've got something in draft now that generates the expected XCFramework: https://github.com/bazelbuild/rules_apple/pull/2459