Skip to content

Commit aea8434

Browse files
authored
Improve iOS unpack target's error messages (flutter#154649)
Improves the formatting and error messages of the target that unpacks the Flutter framework in Flutter iOS builds. Follow up to: flutter#154645 Part of flutter#151567
1 parent 9e99675 commit aea8434

File tree

2 files changed

+47
-23
lines changed
  • packages/flutter_tools

2 files changed

+47
-23
lines changed

packages/flutter_tools/lib/src/build_system/targets/ios.dart

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,20 @@ abstract class UnpackIOS extends Target {
258258

259259
@override
260260
List<Source> get inputs => <Source>[
261-
const Source.pattern(
262-
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/ios.dart'),
263-
Source.artifact(
264-
Artifact.flutterXcframework,
265-
platform: TargetPlatform.ios,
266-
mode: buildMode,
267-
),
268-
];
261+
const Source.pattern(
262+
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/ios.dart',
263+
),
264+
Source.artifact(
265+
Artifact.flutterXcframework,
266+
platform: TargetPlatform.ios,
267+
mode: buildMode,
268+
),
269+
];
269270

270271
@override
271272
List<Source> get outputs => const <Source>[
272-
Source.pattern('{OUTPUT_DIR}/Flutter.framework/Flutter'),
273-
];
273+
Source.pattern('{OUTPUT_DIR}/Flutter.framework/Flutter'),
274+
];
274275

275276
@override
276277
List<Target> get dependencies => <Target>[];
@@ -377,7 +378,12 @@ abstract class UnpackIOS extends Target {
377378
]);
378379

379380
if (verifyResult.exitCode != 0) {
380-
throw Exception('Binary $frameworkBinaryPath does not contain $archs. Running lipo -info:\n$lipoInfo');
381+
throw Exception(
382+
'Binary $frameworkBinaryPath does not contain architectures "$archs".\n'
383+
'\n'
384+
'lipo -info:\n'
385+
'$lipoInfo',
386+
);
381387
}
382388

383389
// Skip thinning for non-fat executables.
@@ -400,7 +406,14 @@ abstract class UnpackIOS extends Target {
400406
]);
401407

402408
if (extractResult.exitCode != 0) {
403-
throw Exception('Failed to extract $archs for $frameworkBinaryPath.\n${extractResult.stderr}\nRunning lipo -info:\n$lipoInfo');
409+
throw Exception(
410+
'Failed to extract architectures "$archs" for $frameworkBinaryPath.\n'
411+
'\n'
412+
'stderr:\n'
413+
'${extractResult.stderr}\n\n'
414+
'lipo -info:\n'
415+
'$lipoInfo',
416+
);
404417
}
405418
}
406419
}

packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import '../../../src/context.dart';
2020
import '../../../src/fake_process_manager.dart';
2121
import '../../../src/fakes.dart';
2222

23-
final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment: <String, String>{});
23+
final Platform macPlatform = FakePlatform(
24+
operatingSystem: 'macos',
25+
environment: <String, String>{},
26+
);
2427

2528
const List<String> _kSharedConfig = <String>[
2629
'-dynamiclib',
@@ -715,7 +718,7 @@ void main() {
715718
fileSystem: fileSystem,
716719
outputDir: outputDir,
717720
defines: <String, String>{
718-
kIosArchs: 'arm64 armv7',
721+
kIosArchs: 'arm64 x86_64',
719722
kSdkRoot: 'path/to/iPhoneOS.sdk',
720723
},
721724
);
@@ -732,7 +735,7 @@ void main() {
732735
binary.path,
733736
'-verify_arch',
734737
'arm64',
735-
'armv7',
738+
'x86_64',
736739
], exitCode: 1),
737740
]);
738741

@@ -741,7 +744,10 @@ void main() {
741744
throwsA(isException.having(
742745
(Exception exception) => exception.toString(),
743746
'description',
744-
contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'),
747+
contains(
748+
'does not contain architectures "arm64 x86_64".\n\n'
749+
'lipo -info:\nArchitectures in the fat file:',
750+
),
745751
)),
746752
);
747753
});
@@ -757,7 +763,7 @@ void main() {
757763
fileSystem: fileSystem,
758764
outputDir: outputDir,
759765
defines: <String, String>{
760-
kIosArchs: 'arm64 armv7',
766+
kIosArchs: 'arm64 x86_64',
761767
kSdkRoot: 'path/to/iPhoneOS.sdk',
762768
},
763769
);
@@ -774,7 +780,7 @@ void main() {
774780
binary.path,
775781
'-verify_arch',
776782
'arm64',
777-
'armv7',
783+
'x86_64',
778784
]),
779785
FakeCommand(command: <String>[
780786
'lipo',
@@ -783,7 +789,7 @@ void main() {
783789
'-extract',
784790
'arm64',
785791
'-extract',
786-
'armv7',
792+
'x86_64',
787793
binary.path,
788794
], exitCode: 1,
789795
stderr: 'lipo error'),
@@ -794,7 +800,12 @@ void main() {
794800
throwsA(isException.having(
795801
(Exception exception) => exception.toString(),
796802
'description',
797-
contains('Failed to extract arm64 armv7 for output/Flutter.framework/Flutter.\nlipo error\nRunning lipo -info:\nArchitectures in the fat file:'),
803+
contains(
804+
'Failed to extract architectures "arm64 x86_64" for output/Flutter.framework/Flutter.\n\n'
805+
'stderr:\n'
806+
'lipo error\n\n'
807+
'lipo -info:\nArchitectures in the fat file:',
808+
),
798809
)),
799810
);
800811
});
@@ -840,7 +851,7 @@ void main() {
840851
fileSystem: fileSystem,
841852
outputDir: outputDir,
842853
defines: <String, String>{
843-
kIosArchs: 'arm64 armv7',
854+
kIosArchs: 'arm64 x86_64',
844855
kSdkRoot: 'path/to/iPhoneOS.sdk',
845856
},
846857
);
@@ -857,7 +868,7 @@ void main() {
857868
binary.path,
858869
'-verify_arch',
859870
'arm64',
860-
'armv7',
871+
'x86_64',
861872
]),
862873
FakeCommand(command: <String>[
863874
'lipo',
@@ -866,7 +877,7 @@ void main() {
866877
'-extract',
867878
'arm64',
868879
'-extract',
869-
'armv7',
880+
'x86_64',
870881
binary.path,
871882
]),
872883
xattrCommand,

0 commit comments

Comments
 (0)