Skip to content

Commit

Permalink
Fix/support implementation deps in objc library (#2317)
Browse files Browse the repository at this point in the history
Bazel 6.3 supported implementation_deps in objc_library
bazelbuild/bazel#18298 and it seems that we
left out
bazelbuild/rules_swift#1081 (comment)
in fix missing resource collect in private_deps
#2118

I just added implementation_deps in resource collect and test for these
two cases
  • Loading branch information
xinzhengzhang authored Nov 2, 2023
1 parent 17f4203 commit b111be2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apple/internal/aspects/resource_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _apple_resource_aspect_impl(target, ctx):
apple_debug_infos = []
apple_dsym_bundle_infos = []
inherited_apple_resource_infos = []
provider_deps = ["deps", "private_deps"] + collect_args.get("res_attrs", [])
provider_deps = ["deps", "private_deps", "implementation_deps"] + collect_args.get("res_attrs", [])
for attr in provider_deps:
if hasattr(ctx.rule.attr, attr):
targets = getattr(ctx.rule.attr, attr)
Expand Down Expand Up @@ -351,7 +351,7 @@ def _apple_resource_aspect_impl(target, ctx):

apple_resource_aspect = aspect(
implementation = _apple_resource_aspect_impl,
attr_aspects = ["data", "deps", "private_deps", "resources", "structured_resources"],
attr_aspects = ["data", "deps", "private_deps", "implementation_deps", "resources", "structured_resources"],
attrs = dicts.add(
apple_support.action_required_attrs(),
apple_toolchain_utils.shared_attrs(),
Expand Down
55 changes: 55 additions & 0 deletions test/ios_application_resources_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,59 @@ Please verify apple.locales_to_include and apple.locales_to_exclude are defined
expect_log "$error_message"
}

# Tests that the bundled application contains nested resource in private_deps(swift_library) or implementation_deps(objc_library)
function test_nested_private_andimplementation_deps_bundled_with_app() {
create_common_files
touch "app/dummy.swift"

cat > app/BUILD <<EOF
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
objc_library(
name = "res1",
data = [
"@build_bazel_rules_apple//test/testdata/resources:sample.png",
],
)
objc_library(
name = "res2",
data = [
"@build_bazel_rules_apple//test/testdata/resources:view_ios.xib",
],
deps = [":res1"],
)
swift_library(
name = "swift_lib",
srcs = ["dummy.swift"],
private_deps = [":res2"],
)
objc_library(
name = "lib",
srcs = ["main.m"],
implementation_deps = [":swift_lib"],
)
ios_application(
name = "app",
bundle_id = "my.bundle.id",
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = "${MIN_OS_IOS}",
provisioning_profile = "@build_bazel_rules_apple//test/testdata/provisioning:integration_testing_ios.mobileprovision",
deps = [":lib"],
)
EOF

do_build ios //app:app || fail "Should build"

assert_zip_contains "test-bin/app/app.ipa" \
"Payload/app.app/sample.png"
assert_zip_contains "test-bin/app/app.ipa" \
"Payload/app.app/view_ios.nib"
}

run_suite "ios_application bundling with resources tests"

0 comments on commit b111be2

Please sign in to comment.