Skip to content

Commit be64036

Browse files
Expose the info plist as a subtarget and it's path in XcodeData
Summary: To run device builds via Xcode, Xcode needs to know the bundle identifier of the app. Typically, we make this customizable via variable substitution in plist generation, so to get the finalized bundle identifier, we need the generated plist. To achieve this, we do two simple things: 1. expose the path of the generated plist in xcode data 2. add a subtarget to apple_bundle rules to materialize the plist file This will allow us to read this file and extract any necessary information. Reviewed By: milend Differential Revision: D39222239 fbshipit-source-id: 8a5e929fd46f4ba284e4715ffe7bec7e503ba730
1 parent aae3dbd commit be64036

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

prelude/apple/apple_bundle.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ load(":apple_sdk.bzl", "get_apple_sdk_name")
1616
INSTALL_DATA_SUB_TARGET = "install-data"
1717
_INSTALL_DATA_FILE_NAME = "install_apple_data.json"
1818

19+
_PLIST = "plist"
20+
1921
_XCTOOLCHAIN_SUB_TARGET = "xctoolchain"
2022

2123
AppleBundlePartListConstructorParams = record(
@@ -117,10 +119,12 @@ def apple_bundle_impl(ctx: "context") -> ["provider"]:
117119

118120
assemble_bundle(ctx, bundle, apple_bundle_part_list_output.parts, apple_bundle_part_list_output.info_plist_part)
119121

122+
sub_targets[_PLIST] = [DefaultInfo(default_outputs = [apple_bundle_part_list_output.info_plist_part.source])]
123+
120124
sub_targets[_XCTOOLCHAIN_SUB_TARGET] = ctx.attrs._apple_xctoolchain.providers
121125

122126
# Define the xcode data sub target
123-
xcode_data_default_info, xcode_data_info = generate_xcode_data(ctx, "apple_bundle", bundle, _xcode_populate_attributes)
127+
xcode_data_default_info, xcode_data_info = generate_xcode_data(ctx, "apple_bundle", bundle, _xcode_populate_attributes, processed_info_plist = apple_bundle_part_list_output.info_plist_part.source)
124128
sub_targets[XCODE_DATA_SUB_TARGET] = xcode_data_default_info
125129
install_data = generate_install_data(ctx)
126130

@@ -142,11 +146,12 @@ def _has_xctoolchain(ctx: "context") -> bool.type:
142146
default_info = ctx.attrs._apple_xctoolchain[DefaultInfo]
143147
return len(default_info.default_outputs) > 0
144148

145-
def _xcode_populate_attributes(ctx) -> {str.type: ""}:
149+
def _xcode_populate_attributes(ctx, processed_info_plist: "artifact") -> {str.type: ""}:
146150
return {
147151
"deployment_version": get_bundle_min_target_version(ctx),
148152
"has_xctoolchain": _has_xctoolchain(ctx),
149153
"info_plist": ctx.attrs.info_plist,
154+
"processed_info_plist": processed_info_plist,
150155
"product_name": get_product_name(ctx),
151156
"sdk": get_apple_sdk_name(ctx),
152157
}

0 commit comments

Comments
 (0)