Skip to content

Commit 84d51b5

Browse files
tymurmustafaievTimur Mustafaev
andauthored
Removed fake_rule_label from precompiled_apple_resource_bundle_impl and using swift_module instead (#865)
**Why this is needed?** `fake_rule_label` was as a workaround and I'd like to remove it and use swift_module. This pr is a continuation of bazelbuild/rules_apple#2335. If we try to build 2 different targets with same module name - plist generation will fail due to rule name collision as `fake_rule_label` is used, which was created from `swift_module` or `bundle_name` **What has changed?** Using `swift_module` for compiling assets, plists, storyboards, etc. instead of `fake_rule_label`. Now, each plist generation action has it's own rule name which has no name collision **NOTE** This PR Requires `rules_apple` to be at least 3.2.0, so I'll fix tests once it's updated --------- Co-authored-by: Timur Mustafaev <[email protected]>
1 parent d579da2 commit 84d51b5

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

rules/precompiled_apple_resource_bundle.bzl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,6 @@ def _precompiled_apple_resource_bundle_impl(ctx):
3434
current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config)
3535
platform_type = str(current_apple_platform.platform.platform_type)
3636

37-
# The label of this fake_ctx is used as the swift module associated with storyboards, nibs, xibs
38-
# and CoreData models.
39-
# * For storyboards, nibs and xibs: https://github.com/bazelbuild/rules_apple/blob/master/apple/internal/partials/support/resources_support.bzl#L446
40-
# * For CoreData models: https://github.com/bazelbuild/rules_apple/blob/master/apple/internal/partials/support/resources_support.bzl#L57
41-
#
42-
# Such swift module is required in the following cases:
43-
# 1- When the storyboard, nib or xib contains the value <customModuleProvider="target">.
44-
# 2- When the CoreData model sets "Current Product Module" for its Module property.
45-
# If none of above scenarios, the swift module is not important and could be any arbitrary string.
46-
# For the full context see https://github.com/bazel-ios/rules_ios/issues/113
47-
#
48-
# Usage:
49-
# The most common scenario happens when the bundle name is the same as the corresponding swift module.
50-
# If that is not the case, it is possible to customize the swift module by explicitly
51-
# passing a swift_module attr
52-
fake_rule_label = Label("//fake_package:" + (ctx.attr.swift_module or bundle_name))
53-
5437
platform_prerequisites = platform_support.platform_prerequisites(
5538
apple_fragment = ctx.fragments.apple,
5639
config_vars = ctx.var,
@@ -78,7 +61,8 @@ def _precompiled_apple_resource_bundle_impl(ctx):
7861
binary_infoplist = None,
7962
product_type = _FAKE_BUNDLE_PRODUCT_TYPE_BY_PLATFORM_TYPE.get(platform_type, ctx.attr._product_type),
8063
),
81-
rule_label = fake_rule_label,
64+
rule_label = ctx.label,
65+
swift_module = ctx.attr.swift_module or bundle_name,
8266
version = None,
8367
include_executable_name = False,
8468
)
@@ -107,6 +91,8 @@ def _precompiled_apple_resource_bundle_impl(ctx):
10791
paths.join("%s-intermediates" % ctx.label.name, "Info.plist"),
10892
)
10993

94+
# No need to pass swift_module to merge_root_infoplists
95+
partials_args.pop("swift_module")
11096
resource_actions.merge_root_infoplists(
11197
bundle_id = ctx.attr.bundle_id or bundle_identifier_for_bundle(bundle_name),
11298
input_plists = ctx.files.infoplists,

0 commit comments

Comments
 (0)