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

fix dynamic framework loss in implementation_deps #2407

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion apple/internal/aspects/framework_provider_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ load(
# these are supported by `objc_library` for frameworks that should be present in the bundle, but not
# linked against.
# TODO(b/120205406): Remove `runtime_deps` support to use objc_library/swift_library `data` instead.
_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = ["deps", "frameworks", "private_deps", "runtime_deps", "data"]
_FRAMEWORK_PROVIDERS_ASPECT_ATTRS = ["deps", "frameworks", "private_deps", "implementation_deps", "runtime_deps", "data"]

def _framework_provider_aspect_impl(target, ctx):
"""Implementation of the framework provider propagation aspect."""
Expand Down
73 changes: 73 additions & 0 deletions test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_implementation_depending_imported_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_implementation_depending_imported_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_imported_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -82,6 +100,25 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_private_depending_imported_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_with_private_depending_imported_objc_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers",
"$BUNDLE_ROOT/Frameworks/libswiftCore.dylib",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/generated_dynamic_xcframework_with_headers.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/generated_dynamic_xcframework_with_headers.framework/generated_dynamic_xcframework_with_headers (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -100,6 +137,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_contains_implementation_depending_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_implementation_depending_imported_swift_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader (offset 24)",
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
Expand All @@ -118,6 +173,24 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
archive_contents_test(
name = "{}_swift_contains_private_depending_imported_swift_xcframework_framework_files".format(name),
build_type = "simulator",
target_under_test = "//test/starlark_tests/targets_under_test/ios:swift_app_with_private_depending_imported_swift_xcframework",
contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Info.plist",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader",
],
not_contains = [
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Headers/",
"$BUNDLE_ROOT/Frameworks/Swift3PFmwkWithGenHeader.framework/Modules/",
],
binary_test_file = "$BINARY",
macho_load_commands_contain = [
"name @rpath/Swift3PFmwkWithGenHeader.framework/Swift3PFmwkWithGenHeader (offset 24)",
],
tags = [name],
)

# Verify the correct XCFramework library was bundled and sliced for the required architecture.
binary_contents_test(
Expand Down
102 changes: 102 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,32 @@ objc_library(
deps = [":ios_imported_dynamic_xcframework"],
)

ios_application(
name = "app_with_implementation_depending_imported_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
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 = [
":dynamic_xcframework_implementation_depending_lib",
"//test/starlark_tests/resources:objc_main_lib",
],
)

objc_library(
name = "dynamic_xcframework_implementation_depending_lib",
srcs = [":dynamic_xcframework_depending_lib_file"],
implementation_deps = [":ios_imported_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "dynamic_xcframework_depending_lib_file",
out = "lib_with_imported_objc_xcframework.m",
Expand Down Expand Up @@ -2348,6 +2374,31 @@ swift_library(
deps = [":ios_imported_dynamic_xcframework"],
)

ios_application(
name = "swift_app_with_private_depending_imported_objc_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
tags = common.fixture_tags,
deps = [
":dynamic_objc_xcframework_private_depending_swift_lib",
"//test/starlark_tests/resources:swift_main_lib",
],
)

swift_library(
name = "dynamic_objc_xcframework_private_depending_swift_lib",
srcs = [":swift_with_framework_src"],
private_deps = [":ios_imported_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "swift_with_framework_src",
out = "SwiftWithObjcFramework.swift",
Expand Down Expand Up @@ -2418,6 +2469,32 @@ objc_library(
deps = [":ios_imported_swift_dynamic_xcframework"],
)

ios_application(
name = "app_with_implementation_depending_imported_swift_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
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 = [
":dynamic_swift_xcframework_implementation_depending_objc_lib",
"//test/starlark_tests/resources:objc_main_lib",
],
)

objc_library(
name = "dynamic_swift_xcframework_implementation_depending_objc_lib",
srcs = [":objc_with_framework_src"],
implementation_deps = [":ios_imported_swift_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "objc_with_framework_src",
out = "ObjcWithFramework.m",
Expand Down Expand Up @@ -2459,6 +2536,31 @@ swift_library(
deps = [":ios_imported_swift_dynamic_xcframework"],
)

ios_application(
name = "swift_app_with_private_depending_imported_swift_xcframework",
bundle_id = "com.google.example",
families = [
"iphone",
"ipad",
],
infoplists = [
"//test/starlark_tests/resources:Info.plist",
],
minimum_os_version = common.min_os_ios.baseline,
tags = common.fixture_tags,
deps = [
":dynamic_swift_xcframework_private_depending_swift_lib",
"//test/starlark_tests/resources:swift_main_lib",
],
)

swift_library(
name = "dynamic_swift_xcframework_private_depending_swift_lib",
srcs = [":swift_with_dynamic_swift_framework_src"],
private_deps = [":ios_imported_swift_dynamic_xcframework"],
tags = common.fixture_tags,
)

write_file(
name = "swift_with_dynamic_swift_framework_src",
out = "SwiftWithDynamicSwiftFramework.swift",
Expand Down