Skip to content
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
3 changes: 2 additions & 1 deletion apple/internal/apple_xcframework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def _classify_xcframework_imports(config_vars, xcframework_imports):

if ".framework/" in file.short_path:
framework_files.append(file)
elif ".framework.dSYM/" in file.short_path:
elif ".dSYM/" in file.short_path:
# dSYMs/ of an XCFramework names a dSYM after the framework or after its binary.
dsym_files.append(file)
else:
xcframework_files.append(file)
Expand Down
11 changes: 6 additions & 5 deletions apple/internal/framework_import_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _classify_file_imports(config_vars, import_files):
if file_extension == "swiftmodule":
swift_module_imports.append(file)
continue
if file_extension == "swiftinterface" and ".framework.dSYM/" not in file.short_path:
if file_extension == "swiftinterface" and ".dSYM/" not in file.short_path:
swift_interface_imports.append(file)
continue
if file_extension in ["swiftdoc", "swiftsourceinfo"]:
Expand All @@ -202,7 +202,7 @@ def _classify_file_imports(config_vars, import_files):
if file_extension == "a":
binary_imports.append(file)
continue
if ".framework.dSYM/" in file.short_path:
if ".dSYM/" in file.short_path:
dsym_imports.append(file)
continue

Expand Down Expand Up @@ -452,10 +452,11 @@ def _get_debug_info_binaries(dsym_binaries, framework_binaries):
for file in dsym_binaries:
dsym_bundle_path = bundle_paths.farthest_parent(
file.short_path,
"framework.dSYM",
"dSYM",
)
dsym_bundle_basename = paths.basename(dsym_bundle_path)
framework_basename = dsym_bundle_basename.rstrip(".dSYM")
framework_basename = paths.basename(dsym_bundle_path)[:-len(".dSYM")]
if not framework_basename.endswith(".framework"):
framework_basename += ".framework"
if framework_basename not in all_binaries_dict:
all_binaries_dict[framework_basename] = file

Expand Down
21 changes: 21 additions & 0 deletions test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,27 @@ def apple_dynamic_xcframework_import_test_suite(name):
],
tags = [name],
)
analysis_output_group_info_files_test(
name = "{}_imported_xcframework_binary_named_dsyms_output_group_files_test".format(name),
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_imported_xcframework_with_binary_named_dsym",
output_group_name = "dsyms",
expected_outputs = [
"generated_dynamic_xcframework_with_binary_named_dsym.xcframework/ios-arm64_x86_64-simulator/dSYMs/generated_dynamic_xcframework_with_binary_named_dsym.dSYM/Contents/Resources/DWARF/generated_dynamic_xcframework_with_binary_named_dsym",
"generated_dynamic_xcframework_with_binary_named_dsym.xcframework/ios-arm64_x86_64-simulator/dSYMs/generated_dynamic_xcframework_with_binary_named_dsym.dSYM/Contents/Info.plist",
"app_with_imported_xcframework_with_binary_named_dsym.app.dSYM/Contents/Resources/DWARF/app_with_imported_xcframework_with_binary_named_dsym",
"app_with_imported_xcframework_with_binary_named_dsym.app.dSYM/Contents/Info.plist",
],
tags = [name],
)
analysis_output_group_info_files_with_xcframework_processor_test(
name = "{}_imported_xcframework_binary_named_dsyms_output_group_files_test_with_xcframework_import_tool".format(name),
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_imported_xcframework_with_binary_named_dsym",
output_group_name = "dsyms",
expected_outputs = [
"ios_imported_dynamic_xcframework_with_binary_named_dsym-intermediates/dsym_imports/generated_dynamic_xcframework_with_binary_named_dsym.framework.dSYM",
],
tags = [name],
)
analysis_output_group_info_files_with_xcframework_processor_test(
name = "{}_imported_xcframework_dsyms_output_group_files_test_with_xcframework_import_tool".format(name),
target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_imported_xcframework",
Expand Down
11 changes: 10 additions & 1 deletion test/starlark_tests/rules/generate_xcframework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _create_xcframework(
sibling = info_plist,
))

prefix, ext, _ = file.path.partition(".framework.dSYM")
prefix, ext, _ = file.path.partition(".dSYM")
dsym_bundle_path = prefix + ext

sets.insert(dsym_bundles_set, dsym_bundle_path)
Expand Down Expand Up @@ -207,6 +207,7 @@ def _generate_dynamic_xcframework_impl(ctx):
platforms = ctx.attr.platforms
minimum_os_versions = ctx.attr.minimum_os_versions
include_versioned_frameworks = ctx.attr.include_versioned_frameworks
dsym_name = label.name if ctx.attr.dsym_named_after_binary else ""

if platforms.keys() != minimum_os_versions.keys():
fail("Attributes: 'platforms' and 'minimum_os_versions' must define the same keys")
Expand Down Expand Up @@ -275,6 +276,7 @@ def _generate_dynamic_xcframework_impl(ctx):
actions = ctx.actions,
apple_fragment = apple_fragment,
base_path = library_identifier,
dsym_name = dsym_name,
framework_binary = binary,
label = label,
xcode_config = xcode_config,
Expand Down Expand Up @@ -631,6 +633,13 @@ Flag to indicate if the framework should include additional versions of the fram
Versions directory. This is only supported for macOS platform.
""",
),
"dsym_named_after_binary": attr.bool(
default = False,
doc = """
Flag to indicate if dSYMs should be named after the framework binary (`<name>.dSYM`) instead of
the framework (`<name>.framework.dSYM`).
""",
),
} | _GENERATE_XCFRAMEWORK_TOOL_ATTRS,
),
fragments = ["apple", "cpp"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ for framework in "${frameworks[@]+"${frameworks[@]}"}"; do
# -debug-symbols arguments must be positioned next to their respective -framework,
# and must be absolute physical paths (no symlinks)
for dsym in "${debug_symbols[@]+"${debug_symbols[@]}"}"; do
if [[ "$dsym" == *$framework_target/$framework_name.dSYM ]]; then
# A dSYM is named after the framework or after its binary.
if [[ "$dsym" == *$framework_target/$framework_name.dSYM ||
"$dsym" == *$framework_target/${framework_name%.framework}.dSYM ]]; then
create_xcframework_args+=("-debug-symbols" "$(realpath "$dsym")")
fi
done
Expand Down
6 changes: 5 additions & 1 deletion test/starlark_tests/rules/generation_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def _create_dsym(
apple_fragment,
base_path = "",
bundle_name = "",
dsym_name = "",
framework_binary,
label,
xcode_config):
Expand All @@ -613,12 +614,15 @@ def _create_dsym(
apple_fragment: An Apple fragment (ctx.fragments.apple).
base_path: Base path for the generated archive file (optional).
bundle_name: Name of the framework bundle (optional).
dsym_name: Name of the dSYM bundle without the `.dSYM` extension (optional). Defaults to
`<bundle_name>.framework`.
framework_binary: A `File` referring to the framework binary.
label: Label of the target being built.
xcode_config: The `apple_common.XcodeVersionConfig` provider from the context.
"""
bundle_name = bundle_name or label.name
bundle_directory = paths.join(base_path, bundle_name + ".framework.dSYM")
dsym_name = dsym_name or bundle_name + ".framework"
bundle_directory = paths.join(base_path, dsym_name + ".dSYM")

# Generate dSYM bundle's DWARF binary
dsym_binary_file = intermediates.file(
Expand Down
48 changes: 48 additions & 0 deletions test/starlark_tests/targets_under_test/ios/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,54 @@ apple_dynamic_xcframework_import(
xcframework_imports = [":generated_dynamic_xcframework_with_headers"],
)

# Objective-C app with an imported XCFramework whose dSYMs are named after the binary.
ios_application(
name = "app_with_imported_xcframework_with_binary_named_dsym",
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 = [
":ios_imported_dynamic_xcframework_with_binary_named_dsym",
"//test/starlark_tests/resources:objc_main_lib",
],
)

apple_dynamic_xcframework_import(
name = "ios_imported_dynamic_xcframework_with_binary_named_dsym",
features = ["-swift.layering_check"],
tags = common.fixture_tags,
xcframework_imports = [":generated_dynamic_xcframework_with_binary_named_dsym"],
)

generate_dynamic_xcframework(
name = "generated_dynamic_xcframework_with_binary_named_dsym",
srcs = ["//test/starlark_tests/resources/frameworks:SharedClass.m"],
hdrs = ["//test/starlark_tests/resources/frameworks:SharedClass.h"],
dsym_named_after_binary = True,
minimum_os_versions = {
"ios_simulator": common.min_os_ios.baseline,
"ios": common.min_os_ios.baseline,
},
platforms = {
"ios_simulator": [
"x86_64",
"arm64",
],
"ios": [
"arm64",
"arm64e",
],
},
tags = common.fixture_tags,
)

generate_dynamic_xcframework(
name = "generated_dynamic_xcframework_with_headers",
srcs = ["//test/starlark_tests/resources/frameworks:SharedClass.m"],
Expand Down