@@ -81,19 +81,28 @@ def _new_entitlements_artifact(*, actions, extension, label_name):
8181 "entitlements/%s%s" % (label_name , extension ),
8282 )
8383
84- def _include_debug_entitlements (* , platform_prerequisites ):
85- """Returns a value indicating whether debug entitlements should be used .
84+ def _force_debug_entitlements (* , platform_prerequisites ):
85+ """Returns a value indicating whether the `get-task-allow` debug entitlements should be forced .
8686
87- Debug entitlements are used if the --device_debug_entitlements command-line
88- option indicates that they should be included .
87+ Debug entitlements are not forced on macOS at this level, regardless of the
88+ apple.add_debugger_entitlement define .
8989
90- Debug entitlements are also not used on macOS.
90+ Debug entitlements are forced if the apple.add_debugger_entitlement define indicates that they
91+ should be included, and if it is not present, they are not.
92+
93+ Note however that if `get-task-allow` is in the provisioning profile, `get-task-allow` will
94+ still be included in the evaluated entitlements file for code signing even if this function
95+ returns False, on account of plisttool's behavior.
96+
97+ Therefore, the ONLY practical effect of this function is to allow for debugging simulator
98+ targets that don't have provisioning profiles assigned if apple.add_debugger_entitlement is set
99+ to True.
91100
92101 Args:
93102 platform_prerequisites: Struct containing information on the platform being targeted.
94103
95104 Returns:
96- True if the debug entitlements should be included , otherwise False.
105+ True if the `get-task-allow` debug entitlements should be forced , otherwise False.
97106 """
98107 if platform_prerequisites .platform_type == apple_common .platform_type .macos :
99108 return False
@@ -104,9 +113,13 @@ def _include_debug_entitlements(*, platform_prerequisites):
104113 )
105114 if add_debugger_entitlement != None :
106115 return add_debugger_entitlement
107- if not platform_prerequisites .objc_fragment .uses_device_debug_entitlements :
108- return False
109- return True
116+
117+ # TODO: b/473768498 - Consider if this should return True for the simulator with no provisioning
118+ # profile case that needs to be handled here, and if we can entirely drop the
119+ # apple.add_debugger_entitlement define support above in favor of that simplification. One means
120+ # would be to have an explicit "if not device -> return True else False" as the entire
121+ # implementation of this function.
122+ return False
110123
111124def _include_app_clip_entitlements (* , product_type ):
112125 """Returns a value indicating whether app clip entitlements should be used.
@@ -268,7 +281,7 @@ def _process_entitlements(
268281 forced_plists = []
269282 if signing_info .entitlements :
270283 plists .append (signing_info .entitlements )
271- if _include_debug_entitlements (platform_prerequisites = platform_prerequisites ):
284+ if _force_debug_entitlements (platform_prerequisites = platform_prerequisites ):
272285 get_task_allow = {"get-task-allow" : True }
273286 forced_plists .append (struct (** get_task_allow ))
274287 if _include_app_clip_entitlements (product_type = product_type ):
@@ -351,7 +364,7 @@ def _process_entitlements(
351364 )
352365
353366 simulator_entitlements = None
354- if _include_debug_entitlements (platform_prerequisites = platform_prerequisites ):
367+ if _force_debug_entitlements (platform_prerequisites = platform_prerequisites ):
355368 simulator_entitlements = actions .declare_file (
356369 "%s_entitlements.simulator.entitlements" % rule_label .name ,
357370 )
0 commit comments