Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bundling live activities extensions with ios_app_clip #2630

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,11 @@ def _ios_app_clip_impl(ctx):
suffix_default = ctx.attr._bundle_id_suffix_default,
shared_capabilities = ctx.attr.shared_capabilities,
)
embeddable_targets = ctx.attr.frameworks
bundle_verification_targets = [struct(target = ext) for ext in ctx.attr.extensions]
embeddable_targets = (
ctx.attr.frameworks +
ctx.attr.extensions
)
executable_name = ctx.attr.executable_name
features = features_support.compute_enabled_features(
requested_features = ctx.features,
Expand Down Expand Up @@ -715,14 +719,15 @@ def _ios_app_clip_impl(ctx):
platform_prerequisites = platform_prerequisites,
provisioning_profile = getattr(ctx.file, "provisioning_profile", None),
rule_descriptor = rule_descriptor,
targets = ctx.attr.deps + ctx.attr.frameworks,
targets = ctx.attr.deps + ctx.attr.extensions + ctx.attr.frameworks,
),
partials.resources_partial(
actions = actions,
apple_mac_toolchain_info = apple_mac_toolchain_info,
bundle_extension = bundle_extension,
bundle_id = bundle_id,
bundle_name = bundle_name,
bundle_verification_targets = bundle_verification_targets,
environment_plist = ctx.file._environment_plist,
executable_name = executable_name,
launch_storyboard = ctx.file.launch_storyboard,
Expand Down Expand Up @@ -2699,6 +2704,14 @@ The `.storyboard` or `.xib` file that should be used as the launch screen for th
provided file will be compiled into the appropriate format (`.storyboardc` or `.nib`) and placed in
the root of the final bundle. The generated file will also be registered in the bundle's
Info.plist under the key `UILaunchStoryboardName`.
""",
),
"extensions": attr.label_list(
providers = [[AppleBundleInfo, IosExtensionBundleInfo]],
doc = """
A list of ios_extension live activity extensions to include in the final app clip bundle.
It is only possible to embed live activity WidgetKit extensions.
Visit Apple developer documentation page for more info https://developer.apple.com/documentation/appclip/offering-live-activities-with-your-app-clip.
""",
),
},
Expand Down
9 changes: 5 additions & 4 deletions doc/rules-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<pre>
ios_app_clip(<a href="#ios_app_clip-name">name</a>, <a href="#ios_app_clip-deps">deps</a>, <a href="#ios_app_clip-resources">resources</a>, <a href="#ios_app_clip-additional_linker_inputs">additional_linker_inputs</a>, <a href="#ios_app_clip-app_icons">app_icons</a>, <a href="#ios_app_clip-bundle_id">bundle_id</a>,
<a href="#ios_app_clip-bundle_id_suffix">bundle_id_suffix</a>, <a href="#ios_app_clip-bundle_name">bundle_name</a>, <a href="#ios_app_clip-codesign_inputs">codesign_inputs</a>, <a href="#ios_app_clip-codesignopts">codesignopts</a>, <a href="#ios_app_clip-entitlements">entitlements</a>,
<a href="#ios_app_clip-entitlements_validation">entitlements_validation</a>, <a href="#ios_app_clip-executable_name">executable_name</a>, <a href="#ios_app_clip-exported_symbols_lists">exported_symbols_lists</a>, <a href="#ios_app_clip-families">families</a>, <a href="#ios_app_clip-frameworks">frameworks</a>,
<a href="#ios_app_clip-infoplists">infoplists</a>, <a href="#ios_app_clip-ipa_post_processor">ipa_post_processor</a>, <a href="#ios_app_clip-launch_storyboard">launch_storyboard</a>, <a href="#ios_app_clip-linkopts">linkopts</a>, <a href="#ios_app_clip-locales_to_include">locales_to_include</a>,
<a href="#ios_app_clip-minimum_deployment_os_version">minimum_deployment_os_version</a>, <a href="#ios_app_clip-minimum_os_version">minimum_os_version</a>, <a href="#ios_app_clip-platform_type">platform_type</a>, <a href="#ios_app_clip-provisioning_profile">provisioning_profile</a>,
<a href="#ios_app_clip-shared_capabilities">shared_capabilities</a>, <a href="#ios_app_clip-stamp">stamp</a>, <a href="#ios_app_clip-strings">strings</a>, <a href="#ios_app_clip-version">version</a>)
<a href="#ios_app_clip-entitlements_validation">entitlements_validation</a>, <a href="#ios_app_clip-executable_name">executable_name</a>, <a href="#ios_app_clip-exported_symbols_lists">exported_symbols_lists</a>, <a href="#ios_app_clip-extensions">extensions</a>, <a href="#ios_app_clip-families">families</a>,
<a href="#ios_app_clip-frameworks">frameworks</a>, <a href="#ios_app_clip-infoplists">infoplists</a>, <a href="#ios_app_clip-ipa_post_processor">ipa_post_processor</a>, <a href="#ios_app_clip-launch_storyboard">launch_storyboard</a>, <a href="#ios_app_clip-linkopts">linkopts</a>,
<a href="#ios_app_clip-locales_to_include">locales_to_include</a>, <a href="#ios_app_clip-minimum_deployment_os_version">minimum_deployment_os_version</a>, <a href="#ios_app_clip-minimum_os_version">minimum_os_version</a>, <a href="#ios_app_clip-platform_type">platform_type</a>,
<a href="#ios_app_clip-provisioning_profile">provisioning_profile</a>, <a href="#ios_app_clip-shared_capabilities">shared_capabilities</a>, <a href="#ios_app_clip-stamp">stamp</a>, <a href="#ios_app_clip-strings">strings</a>, <a href="#ios_app_clip-version">version</a>)
</pre>

Builds and bundles an iOS App Clip.
Expand All @@ -36,6 +36,7 @@ Builds and bundles an iOS App Clip.
| <a id="ios_app_clip-entitlements_validation"></a>entitlements_validation | An `entitlements_validation_mode` to control the validation of the requested entitlements against the provisioning profile to ensure they are supported. | String | optional | `"loose"` |
| <a id="ios_app_clip-executable_name"></a>executable_name | The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the `bundle_name` attribute will be used if it is set; if not, then the name of the target will be used instead. | String | optional | `""` |
| <a id="ios_app_clip-exported_symbols_lists"></a>exported_symbols_lists | A list of targets containing exported symbols lists files for the linker to control symbol resolution.<br><br>Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as `__private_extern__` (aka `visibility=hidden`) and will not be global in the output file.<br><br>See the man page documentation for `ld(1)` on macOS for more details. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
| <a id="ios_app_clip-extensions"></a>extensions | A list of ios_extension live activity extensions to include in the final app clip bundle. It is only possible to embed live activity WidgetKit extensions. Visit Apple developer documentation page for more info https://developer.apple.com/documentation/appclip/offering-live-activities-with-your-app-clip. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
| <a id="ios_app_clip-families"></a>families | A list of device families supported by this rule. At least one must be specified. | List of strings | required | |
| <a id="ios_app_clip-frameworks"></a>frameworks | A list of framework targets (see [`ios_framework`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-ios.md#ios_framework)) that this target depends on. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
| <a id="ios_app_clip-infoplists"></a>infoplists | A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see [Info.plist Handling](https://github.com/bazelbuild/rules_apple/blob/master/doc/common_info.md#infoplist-handling) for what is supported. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
Expand Down
11 changes: 11 additions & 0 deletions test/starlark_tests/ios_app_clip_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ def ios_app_clip_test_suite(name):
tags = [name],
)

# Tests inclusion of extensions.
archive_contents_test(
name = "{}_contains_ios_extension".format(name),
build_type = "device",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_clip_with_ext",
contains = [
"$BUNDLE_ROOT/PlugIns/swift_ios_app_clip_ext.appex/swift_ios_app_clip_ext",
],
tags = [name],
)

native.test_suite(
name = name,
tags = [name],
Expand Down
35 changes: 35 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,22 @@ ios_extension(
],
)

ios_extension(
name = "swift_ios_app_clip_ext",
bundle_id = "com.google.example.clip.ext",
entitlements = "//test/starlark_tests/resources:entitlements.plist",
families = ["iphone"],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
tags = common.fixture_tags,
deps = [
"//test/starlark_tests/resources:swift_main_lib",
],
)

ios_extension(
name = "extensionkit_ext",
bundle_id = "com.google.example.ext",
Expand Down Expand Up @@ -4468,6 +4484,25 @@ ios_app_clip(
],
)

ios_app_clip(
name = "app_clip_with_ext",
bundle_id = "com.google.example.clip",
entitlements = "//test/starlark_tests/resources:entitlements.plist",
extensions = [":swift_ios_app_clip_ext"],
families = ["iphone"],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.appclip_support,
provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision",
tags = common.fixture_tags,
deps = [
":objc_lib_with_ios_framework",
":swift_lib_with_ios_framework",
"//test/starlark_tests/resources:objc_main_lib",
],
)

# ---------------------------------------------------------------------------------------
# Targets for importing XCFramework tests.

Expand Down