Skip to content

Commit c4fcd9c

Browse files
authored
Revert "Support multiple modules on app_intents for applications (#2879)" (#2906)
# Background This reverts commit f92f668. solves #2901 This issue is a regression introduced by #2879, which added support for multiple dependencies for app_intents. The approach was as follows: 1. Parse each dependency module 2. Merge the generated metadata into a single dummy module's metadata using the `--static-metadata-file-list` option of `appintentmetadataprocessor`, which is intended to propagate dependency metadata (definition of `AppIntents`) to dependents 3. Bundle the result of step 2 into the app However, it turns out that `--static-metadata-file-list` does not propagate AppShortcutsProvider to dependent modules. In other words, the processor only recognizes providers defined in the last (root) module it processes. Since the root module in this approach is a dummy module, providers defined in modules passed to `app_intents` are dropped during step 2. # Approach Let me revert it now and start over thinking about proper approach. Now I’m thinking it would be better to keep the single-module restriction for the app_intents argument. Since the processor essentially expects a single root module for defining `AppShortcutsProvider`, it makes sense for app_intents to specify that root module. Instead, it would be more appropriate to support recursively parsing the metadata of dependency modules from the module passed to app_intents, which would effectively allow handling multiple modules. I might try to work on it when I have a time any other idea, suggestion are welcomed BTW, I'm going to open an another PR for adding test cases regarding `AppShortcutsProvider`, it helps us avoiding such regression in the future. I'm sorry for causing this problem and thanks for reviewers, contributors support 🙇
1 parent 346b136 commit c4fcd9c

File tree

11 files changed

+37
-285
lines changed

11 files changed

+37
-285
lines changed

apple/internal/partials/app_intents_metadata_bundle.bzl

Lines changed: 27 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
load("@bazel_skylib//lib:partial.bzl", "partial")
1818
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
19-
load("//apple/internal:intermediates.bzl", "intermediates")
2019
load("//apple/internal:processor.bzl", "processor")
2120
load(
2221
"//apple/internal/providers:app_intents_info.bzl",
@@ -46,89 +45,33 @@ def _app_intents_metadata_bundle_partial_impl(
4645
# available archs.
4746
first_cc_toolchain_key = cc_toolchains.keys()[0]
4847

49-
metadata_bundle = None
50-
if platform_prerequisites.xcode_version_config.xcode_version() >= apple_common.dotted_version("26.0"):
51-
per_dep_metadata_bundles = []
52-
for dep in deps[first_cc_toolchain_key]:
53-
per_dep_metadata_bundles.append(
54-
generate_app_intents_metadata_bundle(
55-
actions = actions,
56-
apple_fragment = platform_prerequisites.apple_fragment,
57-
constvalues_files = dep[AppIntentsInfo].swiftconstvalues_files,
58-
intents_module_names = dep[AppIntentsInfo].intent_module_names,
59-
label = label.relative(label.name + dep[AppIntentsInfo].intent_module_names[0]),
60-
dependency_metadata_bundles = [],
61-
platform_prerequisites = platform_prerequisites,
62-
source_files = dep[AppIntentsInfo].swift_source_files,
63-
target_triples = [
64-
cc_toolchain[cc_common.CcToolchainInfo].target_gnu_system_name
65-
for cc_toolchain in cc_toolchains.values()
66-
],
67-
xcode_version_config = platform_prerequisites.xcode_version_config,
68-
json_tool = json_tool,
69-
),
70-
)
71-
72-
# Merge multiple intent metadatas into a single.
73-
dummy_source_file = intermediates.file(
74-
actions = actions,
75-
target_name = label.name,
76-
output_discriminator = None,
77-
file_name = "{}_app_intents_dummy_source.swift".format(label.name),
78-
)
79-
dummy_constvalues_file = intermediates.file(
80-
actions = actions,
81-
target_name = label.name,
82-
output_discriminator = None,
83-
file_name = "{}_app_intents_dummy_constvalues.swiftconstvalues".format(label.name),
84-
)
85-
actions.write(output = dummy_source_file, content = "")
86-
actions.write(output = dummy_constvalues_file, content = "[]")
87-
metadata_bundle = generate_app_intents_metadata_bundle(
88-
actions = actions,
89-
apple_fragment = platform_prerequisites.apple_fragment,
90-
constvalues_files = [dummy_constvalues_file],
91-
intents_module_names = ["{}AppIntents".format(label.name)],
92-
label = label,
93-
dependency_metadata_bundles = per_dep_metadata_bundles,
94-
platform_prerequisites = platform_prerequisites,
95-
source_files = [dummy_source_file],
96-
target_triples = [
97-
cc_toolchain[cc_common.CcToolchainInfo].target_gnu_system_name
98-
for cc_toolchain in cc_toolchains.values()
99-
],
100-
xcode_version_config = platform_prerequisites.xcode_version_config,
101-
json_tool = json_tool,
102-
)
103-
else:
104-
metadata_bundle = generate_app_intents_metadata_bundle(
105-
actions = actions,
106-
apple_fragment = platform_prerequisites.apple_fragment,
107-
constvalues_files = [
108-
swiftconstvalues_file
109-
for dep in deps[first_cc_toolchain_key]
110-
for swiftconstvalues_file in dep[AppIntentsInfo].swiftconstvalues_files
111-
],
112-
intents_module_names = [
113-
intent_module_name
114-
for dep in deps[first_cc_toolchain_key]
115-
for intent_module_name in dep[AppIntentsInfo].intent_module_names
116-
],
117-
label = label,
118-
dependency_metadata_bundles = [],
119-
platform_prerequisites = platform_prerequisites,
120-
source_files = [
121-
swift_source_file
122-
for dep in deps[first_cc_toolchain_key]
123-
for swift_source_file in dep[AppIntentsInfo].swift_source_files
124-
],
125-
target_triples = [
126-
cc_toolchain[cc_common.CcToolchainInfo].target_gnu_system_name
127-
for cc_toolchain in cc_toolchains.values()
128-
],
129-
xcode_version_config = platform_prerequisites.xcode_version_config,
130-
json_tool = json_tool,
131-
)
48+
metadata_bundle = generate_app_intents_metadata_bundle(
49+
actions = actions,
50+
apple_fragment = platform_prerequisites.apple_fragment,
51+
constvalues_files = [
52+
swiftconstvalues_file
53+
for dep in deps[first_cc_toolchain_key]
54+
for swiftconstvalues_file in dep[AppIntentsInfo].swiftconstvalues_files
55+
],
56+
intents_module_names = [
57+
intent_module_name
58+
for dep in deps[first_cc_toolchain_key]
59+
for intent_module_name in dep[AppIntentsInfo].intent_module_names
60+
],
61+
label = label,
62+
platform_prerequisites = platform_prerequisites,
63+
source_files = [
64+
swift_source_file
65+
for dep in deps[first_cc_toolchain_key]
66+
for swift_source_file in dep[AppIntentsInfo].swift_source_files
67+
],
68+
target_triples = [
69+
cc_toolchain[cc_common.CcToolchainInfo].target_gnu_system_name
70+
for cc_toolchain in cc_toolchains.values()
71+
],
72+
xcode_version_config = platform_prerequisites.xcode_version_config,
73+
json_tool = json_tool,
74+
)
13275

13376
bundle_location = processor.location.bundle
13477
if str(platform_prerequisites.platform_type) == "macos":

apple/internal/resource_actions/app_intents.bzl

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def generate_app_intents_metadata_bundle(
3434
constvalues_files,
3535
intents_module_names,
3636
label,
37-
dependency_metadata_bundles,
3837
platform_prerequisites,
3938
source_files,
4039
target_triples,
@@ -50,8 +49,6 @@ def generate_app_intents_metadata_bundle(
5049
intents_module_names: List of Strings with the module names corresponding to the modules
5150
found which have intents compiled.
5251
label: Label for the current target (`ctx.label`).
53-
dependency_metadata_bundles: List of Metadata.appintents bundles of dependency modules,
54-
only works on Xcode 26+ toolchain.
5552
platform_prerequisites: Struct containing information on the platform being targeted.
5653
source_files: List of Swift source files implementing the AppIntents protocol.
5754
target_triples: List of Apple target triples from `CcToolchainInfo` providers.
@@ -70,21 +67,6 @@ def generate_app_intents_metadata_bundle(
7067
dir_name = "Metadata.appintents",
7168
)
7269

73-
static_metadata_file_list = None
74-
if dependency_metadata_bundles:
75-
static_metadata_file_list = intermediates.file(
76-
actions = actions,
77-
target_name = label.name,
78-
output_discriminator = None,
79-
file_name = "{}.DependencyStaticMetadataFileList".format(label.name),
80-
)
81-
82-
static_metadata_file_list_content = "\n".join([
83-
"{}{}".format(f.path, "/extract.actionsdata")
84-
for f in dependency_metadata_bundles
85-
]) + "\n"
86-
actions.write(output = static_metadata_file_list, content = static_metadata_file_list_content)
87-
8870
args = actions.args()
8971
args.add("/usr/bin/xcrun")
9072
args.add("appintentsmetadataprocessor")
@@ -115,11 +97,6 @@ Could not find a module name for app_intents. One is required for App Intents me
11597
before_each = "--source-files",
11698
)
11799
transitive_inputs = [depset(source_files)]
118-
if dependency_metadata_bundles:
119-
transitive_inputs.append(depset(dependency_metadata_bundles))
120-
if static_metadata_file_list:
121-
args.add("--static-metadata-file-list", static_metadata_file_list.path)
122-
transitive_inputs.append(depset([static_metadata_file_list]))
123100
args.add("--sdk-root", apple_support.path_placeholders.sdkroot())
124101
platform_type_string = str(platform_prerequisites.platform_type)
125102
platform_family = _PLATFORM_TYPE_TO_PLATFORM_FAMILY[platform_type_string]

test/starlark_tests/ios_application_tests.bzl

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -857,28 +857,18 @@ def ios_application_test_suite(name):
857857
],
858858
)
859859

860-
# Test app with App Intents from multiple modules includes both intents.
861-
archive_contents_test(
862-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_simulator_test".format(name),
863-
build_type = "simulator",
864-
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_app_intent_and_widget_configuration_intent",
865-
text_test_file = "$BUNDLE_ROOT/Metadata.appintents/extract.actionsdata",
866-
text_test_values = [
867-
".*HelloWorldIntent.*",
868-
".*FavoriteSoup.*",
869-
],
870-
tags = [name],
871-
)
872-
archive_contents_test(
873-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_device_test".format(name),
874-
build_type = "device",
860+
# Test app that has two Intents defined as top level modules generates an error message.
861+
analysis_failure_message_test(
862+
name = "{}_with_two_app_intents_and_two_modules_fails".format(name),
875863
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_app_intent_and_widget_configuration_intent",
876-
text_test_file = "$BUNDLE_ROOT/Metadata.appintents/extract.actionsdata",
877-
text_test_values = [
878-
".*HelloWorldIntent.*",
879-
".*FavoriteSoup.*",
864+
expected_error = (
865+
"App Intents must have only one module name for metadata generation to work correctly."
866+
).format(
867+
package = "//test/starlark_tests/targets_under_test/ios",
868+
),
869+
tags = [
870+
name,
880871
],
881-
tags = [name],
882872
)
883873

884874
# Test app with App Intents generates and bundles Metadata.appintents bundle for fat binaries.

test/starlark_tests/macos_application_tests.bzl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -439,30 +439,6 @@ def macos_application_test_suite(name):
439439
tags = [name],
440440
)
441441

442-
# Test app with App Intents from multiple modules includes both intents.
443-
archive_contents_test(
444-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_simulator_test".format(name),
445-
build_type = "simulator",
446-
target_under_test = "//test/starlark_tests/targets_under_test/macos:app_with_app_intent_and_widget_configuration_intent",
447-
text_test_file = "$RESOURCE_ROOT/Metadata.appintents/extract.actionsdata",
448-
text_test_values = [
449-
".*HelloWorldIntent.*",
450-
".*FavoriteSoup.*",
451-
],
452-
tags = [name],
453-
)
454-
archive_contents_test(
455-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_device_test".format(name),
456-
build_type = "device",
457-
target_under_test = "//test/starlark_tests/targets_under_test/macos:app_with_app_intent_and_widget_configuration_intent",
458-
text_test_file = "$RESOURCE_ROOT/Metadata.appintents/extract.actionsdata",
459-
text_test_values = [
460-
".*HelloWorldIntent.*",
461-
".*FavoriteSoup.*",
462-
],
463-
tags = [name],
464-
)
465-
466442
apple_verification_test(
467443
name = "{}_app_intents_metadata_json_keys_sorted_test".format(name),
468444
build_type = "simulator",

test/starlark_tests/resources/BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,13 +1414,6 @@ swift_library(
14141414
tags = common.fixture_tags,
14151415
)
14161416

1417-
swift_library(
1418-
name = "extra_app_intent",
1419-
srcs = ["extra_app_intent.swift"],
1420-
linkopts = ["-Wl,-framework,AppIntents"],
1421-
tags = common.fixture_tags,
1422-
)
1423-
14241417
swift_library(
14251418
name = "swift_concurrency_main_lib",
14261419
srcs = ["concurrency_main.swift"],

test/starlark_tests/resources/extra_app_intent.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/starlark_tests/targets_under_test/macos/BUILD

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,23 +2803,6 @@ macos_application(
28032803
],
28042804
)
28052805

2806-
macos_application(
2807-
name = "app_with_app_intent_and_widget_configuration_intent",
2808-
app_intents = [
2809-
"//test/starlark_tests/resources:app_intent",
2810-
"//test/starlark_tests/resources:widget_configuration_intent",
2811-
],
2812-
bundle_id = "com.google.example",
2813-
infoplists = [
2814-
"//test/starlark_tests/resources:Info.plist",
2815-
],
2816-
minimum_os_version = common.min_os_macos.app_intents_support,
2817-
tags = common.fixture_tags,
2818-
deps = [
2819-
"//test/starlark_tests/resources:objc_main_lib_with_common_lib",
2820-
],
2821-
)
2822-
28232806
# ---------------------------------------------------------------------------------------
28242807
# Targets for base_bundle_id and bundle_id flows with and without shared capabilities.
28252808

test/starlark_tests/targets_under_test/tvos/BUILD

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,24 +1503,6 @@ tvos_application(
15031503
],
15041504
)
15051505

1506-
tvos_application(
1507-
name = "app_with_app_intent_and_extra_app_intent",
1508-
app_intents = [
1509-
"//test/starlark_tests/resources:app_intent",
1510-
"//test/starlark_tests/resources:extra_app_intent",
1511-
],
1512-
bundle_id = "com.google.example",
1513-
infoplists = [
1514-
"//test/starlark_tests/resources:Info.plist",
1515-
],
1516-
minimum_os_version = common.min_os_tvos.app_intents_support,
1517-
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
1518-
tags = common.fixture_tags,
1519-
deps = [
1520-
"//test/starlark_tests/resources:swift_uikit_appdelegate",
1521-
],
1522-
)
1523-
15241506
# ---------------------------------------------------------------------------------------
15251507
# Targets for base_bundle_id and bundle_id flows with and without shared capabilities.
15261508

test/starlark_tests/targets_under_test/watchos/BUILD

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,25 +1306,6 @@ watchos_application(
13061306
],
13071307
)
13081308

1309-
watchos_application(
1310-
name = "app_with_app_intent_and_widget_configuration_intent",
1311-
app_intents = [
1312-
"//test/starlark_tests/resources:app_intent",
1313-
"//test/starlark_tests/resources:widget_configuration_intent",
1314-
],
1315-
bundle_id = "com.google.example",
1316-
entitlements = "//test/starlark_tests/resources:entitlements.plist",
1317-
infoplists = [
1318-
"//test/starlark_tests/resources:WatchosAppInfo.plist",
1319-
],
1320-
minimum_os_version = common.min_os_watchos.app_intents_support,
1321-
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
1322-
tags = common.fixture_tags,
1323-
deps = [
1324-
"//test/starlark_tests/resources:watchkit_single_target_app_main_lib",
1325-
],
1326-
)
1327-
13281309
# ---------------------------------------------------------------------------------------
13291310
# Targets for base_bundle_id and bundle_id flows with and without shared capabilities.
13301311

test/starlark_tests/tvos_application_tests.bzl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -662,30 +662,6 @@ def tvos_application_test_suite(name):
662662
tags = [name],
663663
)
664664

665-
# Test app with App Intents from multiple modules includes both intents.
666-
archive_contents_test(
667-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_simulator_test".format(name),
668-
build_type = "simulator",
669-
target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_app_intent_and_extra_app_intent",
670-
text_test_file = "$BUNDLE_ROOT/Metadata.appintents/extract.actionsdata",
671-
text_test_values = [
672-
".*HelloWorldIntent.*",
673-
".*ExtraIntent.*",
674-
],
675-
tags = [name],
676-
)
677-
archive_contents_test(
678-
name = "{}_two_app_intents_modules_metadata_bundle_contents_for_device_test".format(name),
679-
build_type = "device",
680-
target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_app_intent_and_extra_app_intent",
681-
text_test_file = "$BUNDLE_ROOT/Metadata.appintents/extract.actionsdata",
682-
text_test_values = [
683-
".*HelloWorldIntent.*",
684-
".*ExtraIntent.*",
685-
],
686-
tags = [name],
687-
)
688-
689665
apple_verification_test(
690666
name = "{}_app_intents_metadata_json_keys_sorted_test".format(name),
691667
build_type = "simulator",

0 commit comments

Comments
 (0)