[iOS] Bundle dSYM packages in Flutter.xcframework (flutter/engine#54414)
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 Flutter.xcframework bundle. Issue: https://github.com/flutter/flutter/issues/116493 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
eb8c2bba08
commit
753fd42815
@ -143,11 +143,20 @@ def create_framework( # pylint: disable=too-many-arguments
|
|||||||
print('Cannot find iOS simulator dylib at %s' % simulator_x64_dylib)
|
print('Cannot find iOS simulator dylib at %s' % simulator_x64_dylib)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Compute dsym output paths, if enabled.
|
||||||
|
framework_dsym = None
|
||||||
|
simulator_dsym = None
|
||||||
|
if args.dsym:
|
||||||
|
framework_dsym = os.path.splitext(framework)[0] + '.dSYM'
|
||||||
|
simulator_dsym = os.path.splitext(simulator_framework)[0] + '.dSYM'
|
||||||
|
|
||||||
|
# Emit the framework for physical devices.
|
||||||
shutil.rmtree(framework, True)
|
shutil.rmtree(framework, True)
|
||||||
shutil.copytree(arm64_framework, framework)
|
shutil.copytree(arm64_framework, framework)
|
||||||
framework_binary = os.path.join(framework, 'Flutter')
|
framework_binary = os.path.join(framework, 'Flutter')
|
||||||
process_framework(args, dst, framework, framework_binary)
|
process_framework(args, dst, framework_binary, framework_dsym)
|
||||||
|
|
||||||
|
# Emit the framework for simulators.
|
||||||
if args.simulator_arm64_out_dir is not None:
|
if args.simulator_arm64_out_dir is not None:
|
||||||
shutil.rmtree(simulator_framework, True)
|
shutil.rmtree(simulator_framework, True)
|
||||||
shutil.copytree(simulator_arm64_framework, simulator_framework)
|
shutil.copytree(simulator_arm64_framework, simulator_framework)
|
||||||
@ -159,7 +168,7 @@ def create_framework( # pylint: disable=too-many-arguments
|
|||||||
'lipo', simulator_x64_dylib, simulator_arm64_dylib, '-create', '-output',
|
'lipo', simulator_x64_dylib, simulator_arm64_dylib, '-create', '-output',
|
||||||
simulator_framework_binary
|
simulator_framework_binary
|
||||||
])
|
])
|
||||||
process_framework(args, dst, simulator_framework, simulator_framework_binary)
|
process_framework(args, dst, simulator_framework_binary, simulator_dsym)
|
||||||
else:
|
else:
|
||||||
simulator_framework = simulator_x64_framework
|
simulator_framework = simulator_x64_framework
|
||||||
|
|
||||||
@ -167,14 +176,15 @@ def create_framework( # pylint: disable=too-many-arguments
|
|||||||
# simulator frameworks, or just the x64 simulator framework if only that one
|
# simulator frameworks, or just the x64 simulator framework if only that one
|
||||||
# exists.
|
# exists.
|
||||||
xcframeworks = [simulator_framework, framework]
|
xcframeworks = [simulator_framework, framework]
|
||||||
create_xcframework(location=dst, name='Flutter', frameworks=xcframeworks)
|
dsyms = [simulator_dsym, framework_dsym] if args.dsym else None
|
||||||
|
create_xcframework(location=dst, name='Flutter', frameworks=xcframeworks, dsyms=dsyms)
|
||||||
|
|
||||||
# Add the x64 simulator into the fat framework
|
# Add the x64 simulator into the fat framework.
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'lipo', arm64_dylib, simulator_x64_dylib, '-create', '-output', framework_binary
|
'lipo', arm64_dylib, simulator_x64_dylib, '-create', '-output', framework_binary
|
||||||
])
|
])
|
||||||
|
|
||||||
process_framework(args, dst, framework, framework_binary)
|
process_framework(args, dst, framework_binary, framework_dsym)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@ -215,16 +225,14 @@ def zip_archive(dst):
|
|||||||
subprocess.check_call(['zip', '-r', 'extension_safe_Flutter.dSYM.zip', 'Flutter.dSYM'], cwd=dst)
|
subprocess.check_call(['zip', '-r', 'extension_safe_Flutter.dSYM.zip', 'Flutter.dSYM'], cwd=dst)
|
||||||
|
|
||||||
|
|
||||||
def process_framework(args, dst, framework, framework_binary):
|
def process_framework(args, dst, framework_binary, dsym):
|
||||||
if args.dsym:
|
if dsym:
|
||||||
dsym_out = os.path.splitext(framework)[0] + '.dSYM'
|
subprocess.check_call([DSYMUTIL, '-o', dsym, framework_binary])
|
||||||
subprocess.check_call([DSYMUTIL, '-o', dsym_out, framework_binary])
|
|
||||||
|
|
||||||
if args.strip:
|
if args.strip:
|
||||||
# copy unstripped
|
# copy unstripped
|
||||||
unstripped_out = os.path.join(dst, 'Flutter.unstripped')
|
unstripped_out = os.path.join(dst, 'Flutter.unstripped')
|
||||||
shutil.copyfile(framework_binary, unstripped_out)
|
shutil.copyfile(framework_binary, unstripped_out)
|
||||||
|
|
||||||
subprocess.check_call(['strip', '-x', '-S', framework_binary])
|
subprocess.check_call(['strip', '-x', '-S', framework_binary])
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,15 +22,22 @@ def main():
|
|||||||
help='The framework paths used to create the XCFramework.',
|
help='The framework paths used to create the XCFramework.',
|
||||||
required=True
|
required=True
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--dsyms', nargs='+', help='The dSYM paths to be bundled in the XCFramework.', required=False
|
||||||
|
)
|
||||||
parser.add_argument('--name', help='Name of the XCFramework', type=str, required=True)
|
parser.add_argument('--name', help='Name of the XCFramework', type=str, required=True)
|
||||||
parser.add_argument('--location', help='Output directory', type=str, required=True)
|
parser.add_argument('--location', help='Output directory', type=str, required=True)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
create_xcframework(args.location, args.name, args.frameworks)
|
create_xcframework(args.location, args.name, args.frameworks, args.dsyms)
|
||||||
|
|
||||||
|
|
||||||
def create_xcframework(location, name, frameworks):
|
def create_xcframework(location, name, frameworks, dsyms=None):
|
||||||
|
if dsyms and len(frameworks) != len(dsyms):
|
||||||
|
print('Number of --dsyms must match number of --frameworks exactly.', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
output_dir = os.path.abspath(location)
|
output_dir = os.path.abspath(location)
|
||||||
output_xcframework = os.path.join(output_dir, '%s.xcframework' % name)
|
output_xcframework = os.path.join(output_dir, '%s.xcframework' % name)
|
||||||
|
|
||||||
@ -45,11 +52,13 @@ def create_xcframework(location, name, frameworks):
|
|||||||
# -framework bar/baz.framework -output output/
|
# -framework bar/baz.framework -output output/
|
||||||
command = ['xcrun', 'xcodebuild', '-quiet', '-create-xcframework']
|
command = ['xcrun', 'xcodebuild', '-quiet', '-create-xcframework']
|
||||||
|
|
||||||
for framework in frameworks:
|
|
||||||
command.extend(['-framework', os.path.abspath(framework)])
|
|
||||||
|
|
||||||
command.extend(['-output', output_xcframework])
|
command.extend(['-output', output_xcframework])
|
||||||
|
|
||||||
|
for i in range(len(frameworks)): # pylint: disable=consider-using-enumerate
|
||||||
|
command.extend(['-framework', os.path.abspath(frameworks[i])])
|
||||||
|
if dsyms:
|
||||||
|
command.extend(['-debug-symbols', os.path.abspath(dsyms[i])])
|
||||||
|
|
||||||
subprocess.check_call(command, stdout=open(os.devnull, 'w'))
|
subprocess.check_call(command, stdout=open(os.devnull, 'w'))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user