@@ -114,6 +114,8 @@ load(
114114 "files" ,
115115)
116116
117+ files_utils = files
118+
117119def _has_non_system_swift_modules (* , target ):
118120 """Indicates if the given target references any non-system Swift modules.
119121
@@ -140,6 +142,17 @@ def _has_non_system_swift_modules(*, target):
140142
141143 return False
142144
145+ _XCFRAMEWORK_PLATFORM_NAME = {
146+ "ios" : "ios" ,
147+ "macos" : "macos" ,
148+ "tvos" : "tvos" ,
149+ "watchos" : "watchos" ,
150+ "visionos" : "xros" ,
151+ }
152+
153+ def _xcframework_platform_name (platform ):
154+ return _XCFRAMEWORK_PLATFORM_NAME .get (platform , platform )
155+
143156def _apple_platform_info_for_link_output (* , link_output ):
144157 """Creates an ApplePlatformInfo for a framework slice's target platform.
145158
@@ -306,7 +319,7 @@ def _library_identifier(*, architectures, environment, platform):
306319 in the final XCFramework bundle. This mirrors the formatting for subfolders as given by the
307320 xcodebuild -create-xcframework tool.
308321 """
309- library_identifier = "{}-{}" .format (platform , "_" .join (architectures ))
322+ library_identifier = "{}-{}" .format (_xcframework_platform_name ( platform ) , "_" .join (architectures ))
310323 if environment != "device" :
311324 library_identifier += "-{}" .format (environment )
312325 return library_identifier
@@ -687,7 +700,7 @@ def _apple_xcframework_impl(ctx):
687700 split_attr_keys = link_output .split_attr_keys ,
688701 )
689702
690- environment_plist = files .get_file_with_name (
703+ environment_plist = files_utils .get_file_with_name (
691704 name = "environment_plist_{platform}" .format (
692705 platform = link_output .platform ,
693706 ),
@@ -846,7 +859,7 @@ def _apple_xcframework_impl(ctx):
846859 headers_path = None ,
847860 library_identifier = library_identifier ,
848861 library_path = bundle_name + nested_bundle_extension ,
849- platform = link_output .platform ,
862+ platform = _xcframework_platform_name ( link_output .platform ) ,
850863 ))
851864
852865 root_info_plist = _create_xcframework_root_infoplist (
@@ -919,6 +932,7 @@ apple_xcframework = rule_factory.create_apple_rule(
919932 default = [
920933 "//apple/internal:environment_plist_ios" ,
921934 "//apple/internal:environment_plist_tvos" ,
935+ "//apple/internal:environment_plist_visionos" ,
922936 ],
923937 ),
924938 "bundle_id" : attr .string (
@@ -987,6 +1001,13 @@ A list of strings indicating which architecture should be built for the macOS pl
9871001A dictionary of strings indicating which platform variants should be built for the tvOS platform (
9881002`device` or `simulator`) as keys, and arrays of strings listing which architectures should be
9891003built for those platform variants (for example, `x86_64`, `arm64`) as their values.
1004+ """ ,
1005+ ),
1006+ "visionos" : attr .string_list_dict (
1007+ doc = """
1008+ A dictionary of strings indicating which platform variants should be built for the visionOS platform
1009+ (`device` or `simulator`) as keys, and arrays of strings listing which architectures should be
1010+ built for those platform variants (for example, `arm64`) as their values.
9901011""" ,
9911012 ),
9921013 "minimum_deployment_os_versions" : attr .string_dict (
@@ -1007,6 +1028,7 @@ or `tvos` as keys:
10071028 minimum_os_versions = {
10081029 "ios": "13.0",
10091030 "tvos": "15.0",
1031+ "visionos": "1.0",
10101032 }
10111033""" ,
10121034 mandatory = True ,
@@ -1150,7 +1172,7 @@ def _apple_static_xcframework_impl(ctx):
11501172 headers_path = None ,
11511173 library_identifier = library_identifier ,
11521174 library_path = bundle_name + ".framework" ,
1153- platform = link_output .platform ,
1175+ platform = _xcframework_platform_name ( link_output .platform ) ,
11541176 ),
11551177 )
11561178
@@ -1194,21 +1216,29 @@ def _apple_static_xcframework_impl(ctx):
11941216
11951217 # Collect top_level_infoplists only if bundle_id is set
11961218 top_level_infoplists = []
1219+ environment_plist = None
11971220 if ctx .attr .bundle_id :
11981221 top_level_infoplists = resources .collect (
11991222 attr = ctx .split_attr ,
12001223 res_attrs = ["infoplists" ],
12011224 split_attr_keys = link_output .split_attr_keys ,
12021225 )
12031226
1227+ environment_plist = files_utils .get_file_with_name (
1228+ name = "environment_plist_{platform}" .format (
1229+ platform = link_output .platform ,
1230+ ),
1231+ files = ctx .files ._environment_plist_files ,
1232+ )
1233+
12041234 partial_output = partial .call (partials .resources_partial (
12051235 actions = actions ,
12061236 apple_mac_toolchain_info = apple_mac_toolchain_info ,
12071237 bundle_extension = ".framework" ,
12081238 bundle_id = ctx .attr .bundle_id ,
12091239 bundle_name = bundle_name ,
12101240 # TODO(b/174858377): Select which environment_plist to use based on Apple platform.
1211- environment_plist = ctx . file . _environment_plist_ios ,
1241+ environment_plist = environment_plist ,
12121242 executable_name = executable_name ,
12131243 launch_storyboard = None ,
12141244 output_discriminator = library_identifier ,
@@ -1297,6 +1327,13 @@ apple_static_xcframework = rule_factory.create_apple_rule(
12971327 deps_cfg = transition_support .xcframework_transition ,
12981328 ),
12991329 {
1330+ "_environment_plist_files" : attr .label_list (
1331+ default = [
1332+ "//apple/internal:environment_plist_ios" ,
1333+ "//apple/internal:environment_plist_tvos" ,
1334+ "//apple/internal:environment_plist_visionos" ,
1335+ ],
1336+ ),
13001337 "bundle_id" : attr .string (
13011338 mandatory = False ,
13021339 doc = """
@@ -1313,10 +1350,6 @@ then the name of the `bundle_name` attribute will be used if it is set; if not,
13131350the target will be used instead.
13141351""" ,
13151352 ),
1316- "_environment_plist_ios" : attr .label (
1317- allow_single_file = True ,
1318- default = "//apple/internal:environment_plist_ios" ,
1319- ),
13201353 "avoid_deps" : attr .label_list (
13211354 aspects = [apple_resource_aspect ],
13221355 allow_files = True ,
@@ -1371,6 +1404,20 @@ built for those platform variants (for example, `x86_64`, `arm64`) as their valu
13711404 "macos" : attr .string_list (
13721405 doc = """
13731406A list of strings indicating which architecture should be built for the macOS platform (for example, `x86_64`, `arm64`).
1407+ """ ,
1408+ ),
1409+ "tvos" : attr .string_list_dict (
1410+ doc = """
1411+ A dictionary of strings indicating which platform variants should be built for the tvOS platform (
1412+ `device` or `simulator`) as keys, and arrays of strings listing which architectures should be
1413+ built for those platform variants (for example, `x86_64`, `arm64`) as their values.
1414+ """ ,
1415+ ),
1416+ "visionos" : attr .string_list_dict (
1417+ doc = """
1418+ A dictionary of strings indicating which platform variants should be built for the visionOS platform
1419+ (`device` or `simulator`) as keys, and arrays of strings listing which architectures should be
1420+ built for those platform variants (for example, `arm64`) as their values.
13741421""" ,
13751422 ),
13761423 "minimum_deployment_os_versions" : attr .string_dict (
@@ -1386,8 +1433,14 @@ at compile time. Ensure version specific APIs are guarded with `available` claus
13861433 mandatory = True ,
13871434 doc = """
13881435A dictionary of strings indicating the minimum OS version supported by the target, represented as a
1389- dotted version number (for example, "8.0") as values, with their respective platforms such as `ios`
1390- as keys.
1436+ dotted version number (for example, "8.0") as values, with their respective platforms such as `ios`,
1437+ `tvos`, or `visionos` as keys:
1438+
1439+ minimum_os_versions = {
1440+ "ios": "13.0",
1441+ "tvos": "15.0",
1442+ "visionos": "1.0",
1443+ }
13911444""" ,
13921445 ),
13931446 "public_hdrs" : attr .label_list (
0 commit comments