bazelbuild / rules_apple

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

apple_xcframework: Invalid Info.plist generated for xcframework supporting both device and simulator #2524

Open zavsby opened 2 months ago

zavsby commented 2 months ago

I'm using apple_xcframework to generate a xcframework for ios (arm64 + arm64 simulator). But Info.plist for frameworks is always generated same for simulator and device with same value in CFBundleSupportedPlatforms, DTPlatformName and DTSDKName. It depends what is passed to build command in --ios_multi_cpus or not passed at all, but anyway it is always either iphonesimulator or iphoneos for both ios and simulator frameworks.

apple_xcframework(
    name = "SwiftProtobuf",
    deps = [":SwiftProtobufLib"],
    bundle_id = "org.swift.protobuf.SwiftProtobuf",
    extension_safe = True,
    infoplists = [":Info.plist"],
    ios = {"device": ["arm64"], "simulator": ["arm64"]},
    minimum_os_versions = {"ios": "15.0"},
    minimum_deployment_os_versions = {"ios": "15.0"},
)

swift_library(
    name = "SwiftProtobufLib",
    srcs = glob(["*.swift"]),
    module_name = "SwiftProtobuf",
    features = [
        SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION,
    ]
)

bazel build //Sources/SwiftProtobuf:SwiftProtobuf --apple_platform_type=ios --ios_multi_cpus=sim_arm64,arm64

I've found that issue is in platform_support.bzl in _platform_prerequisites method which returns same platform for any environment. Maybe I'm doing something wrong in configuration and some fix already exists?