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

Commit da4d6cb

Browse files
committed
macOS: Bundle dSYM packages in FlutterMacOS.xcframework
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
1 parent 079c5ec commit da4d6cb

File tree

2 files changed

+41
-31
lines changed

2 files changed

+41
-31
lines changed

sky/tools/create_macos_framework.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def main():
6464

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

6970
if args.zip:
7071
zip_framework(dst)
@@ -104,38 +105,51 @@ def zip_framework(dst):
104105

105106
zip_xcframework_archive(dst)
106107

107-
dsym_dst = os.path.join(dst, 'FlutterMacOS.dSYM')
108-
if os.path.exists(dsym_dst):
108+
# Generate Flutter.dSYM.zip for manual symbolification.
109+
#
110+
# Historically, the framework dSYM was named Flutter.dSYM, so in order to
111+
# remain backward-compatible with existing instructions in docs/Crashes.md
112+
# and existing tooling such as dart-lang/dart_ci, we rename back to that name
113+
#
114+
# TODO(cbracken): remove these archives and the upload steps once we bundle
115+
# dSYMs in app archives. https://github.com/flutter/flutter/issues/116493
116+
framework_dsym = framework_dst + '.dSYM'
117+
if os.path.exists(framework_dsym):
118+
renamed_dsym = framework_dsym.replace('FlutterMacOS.framework.dSYM', 'FlutterMacOS.dSYM')
119+
os.rename(framework_dsym, renamed_dsym)
120+
109121
# Create a zip of just the contents of the dSYM, then create a zip of that zip.
110122
# TODO(cbracken): remove this once https://github.com/flutter/flutter/issues/125067 is resolved
111-
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM.zip', ['.'])
112-
sky_utils.create_zip(dsym_dst, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])
123+
sky_utils.create_zip(renamed_dsym, 'FlutterMacOS.dSYM.zip', ['.'])
124+
sky_utils.create_zip(renamed_dsym, 'FlutterMacOS.dSYM_.zip', ['FlutterMacOS.dSYM.zip'])
113125

114126
# Move the double-zipped FlutterMacOS.dSYM.zip to dst.
115-
dsym_final_src_path = os.path.join(dsym_dst, 'FlutterMacOS.dSYM_.zip')
127+
dsym_final_src_path = os.path.join(renamed_dsym, 'FlutterMacOS.dSYM_.zip')
116128
dsym_final_dst_path = os.path.join(dst, 'FlutterMacOS.dSYM.zip')
117129
shutil.move(dsym_final_src_path, dsym_final_dst_path)
118130

119131

120132
def zip_xcframework_archive(dst):
121-
sky_utils.write_codesign_config(os.path.join(dst, 'entitlements.txt'), [])
122-
123-
sky_utils.write_codesign_config(
124-
os.path.join(dst, 'without_entitlements.txt'), [
125-
'FlutterMacOS.xcframework/macos-arm64_x86_64/'
126-
'FlutterMacOS.framework/Versions/A/FlutterMacOS'
127-
]
128-
)
129-
130-
sky_utils.create_zip(
131-
dst,
132-
'framework.zip',
133-
[
134-
'FlutterMacOS.xcframework',
135-
'entitlements.txt',
136-
'without_entitlements.txt',
137-
],
138-
)
133+
# pylint: disable=line-too-long
134+
with_entitlements = []
135+
with_entitlements_file = os.path.join(dst, 'entitlements.txt')
136+
sky_utils.write_codesign_config(with_entitlements_file, with_entitlements)
137+
138+
without_entitlements = [
139+
'FlutterMacOS.xcframework/macos-arm64_x86_64/FlutterMacOS.framework/Versions/A/FlutterMacOS',
140+
'FlutterMacOS.xcframework/macos-arm64_x86_64/dSYMs/FlutterMacOS.framework.dSYM/Contents/Resources/DWARF/FlutterMacOS',
141+
]
142+
without_entitlements_file = os.path.join(dst, 'without_entitlements.txt')
143+
sky_utils.write_codesign_config(without_entitlements_file, without_entitlements)
144+
# pylint: enable=line-too-long
145+
146+
zip_contents = [
147+
'FlutterMacOS.xcframework',
148+
'entitlements.txt',
149+
'without_entitlements.txt',
150+
]
151+
sky_utils.assert_valid_codesign_config(dst, zip_contents, with_entitlements, without_entitlements)
152+
sky_utils.create_zip(dst, 'framework.zip', zip_contents)
139153

140154

141155
if __name__ == '__main__':

sky/tools/sky_utils.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _contains_duplicates(strings):
8484

8585
def _is_macho_binary(filename):
8686
"""Returns True if the specified path is file and a Mach-O binary."""
87-
if not os.path.isfile(filename):
87+
if os.path.islink(filename) or not os.path.isfile(filename):
8888
return False
8989

9090
with open(filename, 'rb') as file:
@@ -128,11 +128,7 @@ def create_fat_macos_framework(args, dst, fat_framework, arm64_framework, x64_fr
128128
get_mac_framework_dylib_path(x64_framework)], framework_dylib)
129129
_set_framework_permissions(fat_framework)
130130

131-
# Compute dsym output path, if enabled.
132-
framework_dsym = None
133-
if args.dsym:
134-
framework_dsym = os.path.join(dst, get_framework_name(fat_framework) + '.dSYM')
135-
131+
framework_dsym = fat_framework + '.dSYM' if args.dsym else None
136132
_process_macos_framework(args, dst, framework_dylib, framework_dsym)
137133

138134

@@ -191,7 +187,7 @@ def _set_framework_permissions(framework_dir):
191187

192188

193189
def _process_macos_framework(args, dst, framework_dylib, dsym):
194-
if dsym:
190+
if args.dsym:
195191
extract_dsym(framework_dylib, dsym)
196192

197193
if args.strip:

0 commit comments

Comments
 (0)