@@ -29,6 +29,13 @@ _DEVICE_FAMILY_VALUES = {
2929 "mac" : None ,
3030}
3131
32+ # Align with Migrate apple_common.platform to Starlark implimentaion
33+ TARGET_ENVIROMENT = struct (
34+ device = "device" ,
35+ catalyst = "macabi" ,
36+ simulator = "simulator" ,
37+ )
38+
3239def _ui_device_family_plist_value (* , platform_prerequisites ):
3340 """Returns the value to use for `UIDeviceFamily` in an info.plist.
3441
@@ -72,7 +79,9 @@ def _platform_prerequisites(
7279 objc_fragment ,
7380 platform_type_string ,
7481 uses_swift ,
75- xcode_version_config ):
82+ xcode_version_config ,
83+ environment = None ,
84+ ):
7685 """Returns a struct containing information on the platform being targeted.
7786
7887 Args:
@@ -88,13 +97,26 @@ def _platform_prerequisites(
8897 platform_type_string: The platform type for the current target as a string.
8998 uses_swift: Boolean value to indicate if this target uses Swift.
9099 xcode_version_config: The `apple_common.XcodeVersionConfig` provider from the current context.
100+ environment: "device" or "simulator" environment of the current target. Optional.
91101
92102 Returns:
93103 A struct representing the collected platform information.
94104 """
95105 platform_type_attr = getattr (apple_common .platform_type , platform_type_string )
96106 platform = apple_fragment .multi_arch_platform (platform_type_attr )
97107
108+ if environment == TARGET_ENVIROMENT .simulator :
109+ if platform_type_attr == apple_common .platform_type .ios :
110+ platform = apple_common .platform .ios_simulator
111+ elif platform_type_attr == apple_common .platform_type .tvos :
112+ platform = apple_common .platform .tvos_simulator
113+ elif platform_type_attr == apple_common .platform_type .visionos :
114+ platform = apple_common .platform .tvos_simulator
115+ elif platform_type_attr == apple_common .platform_type .watchos :
116+ platform = apple_common .platform .watchos_simulator
117+ else :
118+ # no `macos_simulator` exists
119+ fail ("Simulator environment is not supported for platform type: %s" % platform_type_string )
98120 if explicit_minimum_os :
99121 minimum_os = explicit_minimum_os
100122 else :
0 commit comments