Skip to content

Commit

Permalink
Fix apple_xcframework framework plist generated for invalid platform
Browse files Browse the repository at this point in the history
  • Loading branch information
zavsby committed Sep 9, 2024
1 parent 5699172 commit 5a59387
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apple/internal/platform_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def _platform_prerequisites(
objc_fragment,
platform_type_string,
uses_swift,
xcode_version_config):
xcode_version_config,
environment = None):
"""Returns a struct containing information on the platform being targeted.
Args:
Expand All @@ -88,12 +89,21 @@ def _platform_prerequisites(
platform_type_string: The platform type for the current target as a string.
uses_swift: Boolean value to indicate if this target uses Swift.
xcode_version_config: The `apple_common.XcodeVersionConfig` provider from the current context.
environment: Specific environment (`device` or `simulator`) for iOS platfrom type. Optional.
Returns:
A struct representing the collected platform information.
"""
platform_type_attr = getattr(apple_common.platform_type, platform_type_string)
platform = apple_fragment.multi_arch_platform(platform_type_attr)

if platform_type_attr == apple_common.platform_type.ios and environment:
if environment == "simulator":
platform = apple_common.platform.ios_simulator
elif environment == "device":
platform = apple_common.platform.ios_device
else:
fail("Unknown iOS environment: %s. It should be either `device` or `simulator`" % environment)
else:
platform = apple_fragment.multi_arch_platform(platform_type_attr)

if explicit_minimum_os:
minimum_os = explicit_minimum_os
Expand Down
2 changes: 2 additions & 0 deletions apple/internal/xcframework_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def _apple_xcframework_impl(ctx):
platform_type_string = link_output.platform,
uses_swift = link_output.uses_swift,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
environment = link_output.environment,
)

overridden_predeclared_outputs = struct(
Expand Down Expand Up @@ -1040,6 +1041,7 @@ def _apple_static_xcframework_impl(ctx):
platform_type_string = link_output.platform,
uses_swift = link_output.uses_swift,
xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig],
environment = link_output.environment,
)
resource_deps = _unioned_attrs(
attr_names = ["deps"],
Expand Down

0 comments on commit 5a59387

Please sign in to comment.