rules_swift
rules_swift copied to clipboard
`private_deps` may lost `data` fields which could cause an unexpected resource lost
Please take a look at this example: https://github.com/xiemotongye/private_deps_data_issue
When we use deps
in swift_library
.
swift_library(
name = "Sources",
srcs = [
"AppDelegate.swift",
],
module_name = "Sources",
#private_deps = [
# "//srcs/A:a_lib",
# "//srcs/B:b_lib",
#]
deps = [
"//srcs/A:a_lib",
"//srcs/B:b_lib",
]
)
Run this command in terminal to build an ipa.
bazel build //:private_deps_demo
Unarchive bazel-bin/private_deps_demo.ipa
, we will see bazel-swift.png
& bazel-objc.png
in Payload.
But when we use private_deps
in swift_library
.
swift_library(
name = "Sources",
srcs = [
"AppDelegate.swift",
],
module_name = "Sources",
private_deps = [
"//srcs/A:a_lib",
"//srcs/B:b_lib",
]
#deps = [
# "//srcs/A:a_lib",
# "//srcs/B:b_lib",
#]
)
We run the same command in terminal to build another ipa.
bazel build //:private_deps_demo
Let's unarchive bazel-bin/private_deps_demo.ipa
again.
This time, there is no bazel-swift.png
& bazel-objc.png
in Payload.
I don't think this is an expected output. This behavior may cause some unexpected resource lost, and it's hard to discover which resources are missing.
We probably just have to adjust (some of?) these locations to also include private_deps
:
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/xcframework_rules.bzl#L541
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/xcframework_rules.bzl#L1011
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L62
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L261
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L295 (this one for sure)
Can you make a PR with the required fix(es), including some tests, and then we can review it?
Bazel 6.3 will support implementation_deps
in objc_library(https://github.com/bazelbuild/bazel/issues/18298) it seems that we need to support this attribute as well
We probably just have to adjust (some of?) these locations to also include
private_deps
:
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/xcframework_rules.bzl#L541
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/xcframework_rules.bzl#L1011
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L62
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L261
- https://github.com/bazelbuild/rules_apple/blob/c678d8d0cbf3767007e303196680ee14a31b78da/apple/internal/aspects/resource_aspect.bzl#L295 (this one for sure)
Can you make a PR with the required fix(es), including some tests, and then we can review it?
OK. I will have a try this week.