Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
macOS: Bundle dSYM packages in FlutterMacOS.xcframework
Browse files Browse the repository at this point in the history
As of Xcode 16, App Store validation requires dSYMs for frameworks in app archives. Bundling dSYMs also significantly simplifies stack trace symbolification, so we should be doing this regardless.

This adds both framework and simulator framework dSYMs to the FlutterMacOS.xcframework bundle.

Issue: flutter/flutter#153879
  • Loading branch information
cbracken committed Aug 22, 2024
1 parent 079c5ec commit aa11d3c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
44 changes: 30 additions & 14 deletions sky/tools/create_macos_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def main():

# Create XCFramework from the arm64 and x64 fat framework.
xcframeworks = [fat_framework]
create_xcframework(location=dst, name='FlutterMacOS', frameworks=xcframeworks)
dsyms = [fat_framework + '.dSYM'] if args.dsym else None
create_xcframework(location=dst, name='FlutterMacOS', frameworks=xcframeworks, dsyms=dsyms)

if args.zip:
zip_framework(dst)
Expand Down Expand Up @@ -104,28 +105,43 @@ def zip_framework(dst):

zip_xcframework_archive(dst)

dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
if os.path.exists(dsym_dst):
# Generate Flutter.dSYM.zip for manual symbolification.
#
# Historically, the framework dSYM was named Flutter.dSYM, so in order to
# remain backward-compatible with existing instructions in docs/Crashes.md
# and existing tooling such as dart-lang/dart_ci, we rename back to that name
#
# TODO(cbracken): remove these archives and the upload steps once we bundle
# dSYMs in app archives. https://github.com/flutter/flutter/issues/116493
framework_dsym = framework_dst + '.dSYM'
if os.path.exists(framework_dsym):
renamed_dsym = framework_dsym.replace('FlutterMacOS.framework.dSYM', 'FlutterMacOS.dSYM')
os.rename(framework_dsym, renamed_dsym)

# Create a zip of just the contents of the dSYM, then create a zip of that zip.
# TODO(cbracken): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])
sky_utils.create_zip(renamed_dsym, 'FlutterMacOS.dSYM.zip', ['.'])
sky_utils.create_zip(renamed_dsym, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])

# Move the double-zipped FlutterMacOS.dSYM.zip to dst.
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
dsym_final_src_path = os.path.join(renamed_dsym, 'FlutterMacOS.dSYM_.zip')
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
shutil.move(dsym_final_src_path, dsym_final_dst_path)


def zip_xcframework_archive(dst):
sky_utils.write_codesign_config(os.path.join(dst, 'entitlements.txt'), [])

sky_utils.write_codesign_config(
os.path.join(dst, 'without_entitlements.txt'), [
'FlutterMacOS.xcframework/macos-arm64_x86_64/'
'FlutterMacOS.framework/Versions/A/FlutterMacOS'
]
)
# pylint: disable=line-too-long
with_entitlements = []
with_entitlements_file = os.path.join(dst, 'entitlements.txt')
sky_utils.write_codesign_config(with_entitlements_file, with_entitlements)

without_entitlements = [
'FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
'FlutterMacOS.xcframework/macos-arm64_x86_64/dSYMs/FlutterMacOS.framework.dSYM/Contents/Resources/DWARF/FlutterMacOS',
]
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
# pylint: enable=line-too-long

sky_utils.create_zip(
dst,
Expand Down
8 changes: 2 additions & 6 deletions sky/tools/sky_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ def create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_fr
get_mac_framework_dylib_path(x64_framework)], framework_dylib)
_set_framework_permissions(fat_framework)

# Compute dsym output path, if enabled.
framework_dsym = None
if args.dsym:
framework_dsym = os.path.join(dst, get_framework_name(fat_framework) + '.dSYM')

framework_dsym = fat_framework + '.dSYM' if args.dsym else None
_process_macos_framework(args, dst, framework_dylib, framework_dsym)


Expand Down Expand Up @@ -191,7 +187,7 @@ def _set_framework_permissions(framework_dir):


def _process_macos_framework(args, dst, framework_dylib, dsym):
if dsym:
if args.dsym:
extract_dsym(framework_dylib, dsym)

if args.strip:
Expand Down

0 comments on commit aa11d3c

Please sign in to comment.