@@ -10,6 +10,7 @@ import 'package:file_testing/file_testing.dart';
10
10
import 'package:flutter_tools/src/artifacts.dart' ;
11
11
import 'package:flutter_tools/src/base/file_system.dart' ;
12
12
import 'package:flutter_tools/src/base/logger.dart' ;
13
+ import 'package:flutter_tools/src/base/os.dart' ;
13
14
import 'package:flutter_tools/src/base/platform.dart' ;
14
15
import 'package:flutter_tools/src/base/version.dart' ;
15
16
import 'package:flutter_tools/src/build_info.dart' ;
@@ -79,6 +80,10 @@ final FakePlatform macPlatform = FakePlatform(
79
80
environment: < String , String > {},
80
81
);
81
82
83
+ final FakeOperatingSystemUtils os = FakeOperatingSystemUtils (
84
+ hostPlatform: HostPlatform .darwin_arm64,
85
+ );
86
+
82
87
void main () {
83
88
late Artifacts artifacts;
84
89
late String iosDeployPath;
@@ -153,6 +158,7 @@ void main() {
153
158
ProcessManager : () => processManager,
154
159
FileSystem : () => fileSystem,
155
160
Logger : () => logger,
161
+ OperatingSystemUtils : () => os,
156
162
Platform : () => macPlatform,
157
163
XcodeProjectInterpreter : () => FakeXcodeProjectInterpreter (buildSettings: const < String , String > {
158
164
'WRAPPER_NAME' : 'My Super Awesome App.app' ,
@@ -243,6 +249,92 @@ void main() {
243
249
ProcessManager : () => processManager,
244
250
FileSystem : () => fileSystem,
245
251
Logger : () => logger,
252
+ OperatingSystemUtils : () => os,
253
+ Platform : () => macPlatform,
254
+ XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
255
+ Xcode : () => xcode,
256
+ });
257
+
258
+ testUsingContext ('ONLY_ACTIVE_ARCH is NO if different host and target architectures' , () async {
259
+ // Host architecture is x64, target architecture is arm64.
260
+ final IOSDevice iosDevice = setUpIOSDevice (
261
+ fileSystem: fileSystem,
262
+ processManager: processManager,
263
+ logger: logger,
264
+ artifacts: artifacts,
265
+ );
266
+ setUpIOSProject (fileSystem);
267
+ final FlutterProject flutterProject = FlutterProject .fromDirectory (fileSystem.currentDirectory);
268
+ final BuildableIOSApp buildableIOSApp = BuildableIOSApp (flutterProject.ios, 'flutter' , 'My Super Awesome App' );
269
+ fileSystem.directory ('build/ios/Release-iphoneos/My Super Awesome App.app' ).createSync (recursive: true );
270
+
271
+ processManager.addCommand (FakeCommand (command: _xattrArgs (flutterProject)));
272
+ processManager.addCommand (const FakeCommand (command: < String > [
273
+ 'xcrun' ,
274
+ 'xcodebuild' ,
275
+ '-configuration' ,
276
+ 'Release' ,
277
+ '-quiet' ,
278
+ '-workspace' ,
279
+ 'Runner.xcworkspace' ,
280
+ '-scheme' ,
281
+ 'Runner' ,
282
+ 'BUILD_DIR=/build/ios' ,
283
+ '-sdk' ,
284
+ 'iphoneos' ,
285
+ '-destination' ,
286
+ 'id=123' ,
287
+ 'ONLY_ACTIVE_ARCH=NO' ,
288
+ 'ARCHS=arm64' ,
289
+ '-resultBundlePath' ,
290
+ '/.tmp_rand0/flutter_ios_build_temp_dirrand0/temporary_xcresult_bundle' ,
291
+ '-resultBundleVersion' ,
292
+ '3' ,
293
+ 'FLUTTER_SUPPRESS_ANALYTICS=true' ,
294
+ 'COMPILER_INDEX_STORE_ENABLE=NO' ,
295
+ ]));
296
+ processManager.addCommand (const FakeCommand (command: < String > [
297
+ 'rsync' ,
298
+ '-8' ,
299
+ '-av' ,
300
+ '--delete' ,
301
+ 'build/ios/Release-iphoneos/My Super Awesome App.app' ,
302
+ 'build/ios/iphoneos' ,
303
+ ]));
304
+ processManager.addCommand (FakeCommand (
305
+ command: < String > [
306
+ iosDeployPath,
307
+ '--id' ,
308
+ '123' ,
309
+ '--bundle' ,
310
+ 'build/ios/iphoneos/My Super Awesome App.app' ,
311
+ '--app_deltas' ,
312
+ 'build/ios/app-delta' ,
313
+ '--no-wifi' ,
314
+ '--justlaunch' ,
315
+ '--args' ,
316
+ const < String > [
317
+ '--enable-dart-profiling' ,
318
+ ].join (' ' ),
319
+ ])
320
+ );
321
+
322
+ final LaunchResult launchResult = await iosDevice.startApp (
323
+ buildableIOSApp,
324
+ debuggingOptions: DebuggingOptions .disabled (BuildInfo .release),
325
+ platformArgs: < String , Object > {},
326
+ );
327
+
328
+ expect (fileSystem.directory ('build/ios/iphoneos' ), exists);
329
+ expect (launchResult.started, true );
330
+ expect (processManager, hasNoRemainingExpectations);
331
+ }, overrides: < Type , Generator > {
332
+ ProcessManager : () => processManager,
333
+ FileSystem : () => fileSystem,
334
+ Logger : () => logger,
335
+ OperatingSystemUtils : () => FakeOperatingSystemUtils (
336
+ hostPlatform: HostPlatform .darwin_x64,
337
+ ),
246
338
Platform : () => macPlatform,
247
339
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
248
340
Xcode : () => xcode,
@@ -362,6 +454,7 @@ void main() {
362
454
ProcessManager : () => FakeProcessManager .any (),
363
455
FileSystem : () => fileSystem,
364
456
Logger : () => logger,
457
+ OperatingSystemUtils : () => os,
365
458
Platform : () => macPlatform,
366
459
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
367
460
Xcode : () => xcode,
@@ -396,6 +489,7 @@ void main() {
396
489
ProcessManager : () => FakeProcessManager .any (),
397
490
FileSystem : () => fileSystem,
398
491
Logger : () => logger,
492
+ OperatingSystemUtils : () => os,
399
493
Platform : () => macPlatform,
400
494
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
401
495
Xcode : () => xcode,
@@ -430,6 +524,7 @@ void main() {
430
524
ProcessManager : () => FakeProcessManager .any (),
431
525
FileSystem : () => fileSystem,
432
526
Logger : () => logger,
527
+ OperatingSystemUtils : () => os,
433
528
Platform : () => macPlatform,
434
529
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
435
530
Xcode : () => xcode,
@@ -465,6 +560,7 @@ void main() {
465
560
ProcessManager : () => FakeProcessManager .any (),
466
561
FileSystem : () => fileSystem,
467
562
Logger : () => logger,
563
+ OperatingSystemUtils : () => os,
468
564
Platform : () => macPlatform,
469
565
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
470
566
Xcode : () => xcode,
@@ -531,6 +627,7 @@ void main() {
531
627
ProcessManager : () => FakeProcessManager .any (),
532
628
FileSystem : () => fileSystem,
533
629
Logger : () => logger,
630
+ OperatingSystemUtils : () => os,
534
631
Platform : () => macPlatform,
535
632
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
536
633
Xcode : () => xcode,
@@ -606,6 +703,7 @@ void main() {
606
703
ProcessManager : () => FakeProcessManager .any (),
607
704
FileSystem : () => fileSystem,
608
705
Logger : () => logger,
706
+ OperatingSystemUtils : () => os,
609
707
Platform : () => macPlatform,
610
708
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
611
709
Xcode : () => xcode,
@@ -686,6 +784,7 @@ void main() {
686
784
ProcessManager : () => FakeProcessManager .any (),
687
785
FileSystem : () => fileSystem,
688
786
Logger : () => logger,
787
+ OperatingSystemUtils : () => os,
689
788
Platform : () => macPlatform,
690
789
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
691
790
Xcode : () => xcode,
@@ -764,6 +863,7 @@ void main() {
764
863
ProcessManager : () => FakeProcessManager .any (),
765
864
FileSystem : () => fileSystem,
766
865
Logger : () => logger,
866
+ OperatingSystemUtils : () => os,
767
867
Platform : () => macPlatform,
768
868
XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
769
869
Xcode : () => xcode,
@@ -839,6 +939,7 @@ IOSDevice setUpIOSDevice({
839
939
bool isCoreDevice = false ,
840
940
IOSCoreDeviceControl ? coreDeviceControl,
841
941
FakeXcodeDebug ? xcodeDebug,
942
+ DarwinArch cpuArchitecture = DarwinArch .arm64,
842
943
}) {
843
944
artifacts ?? = Artifacts .test ();
844
945
final Cache cache = Cache .test (
@@ -872,7 +973,7 @@ IOSDevice setUpIOSDevice({
872
973
),
873
974
coreDeviceControl: coreDeviceControl ?? FakeIOSCoreDeviceControl (),
874
975
xcodeDebug: xcodeDebug ?? FakeXcodeDebug (),
875
- cpuArchitecture: DarwinArch .arm64 ,
976
+ cpuArchitecture: cpuArchitecture ,
876
977
connectionInterface: DeviceConnectionInterface .attached,
877
978
isConnected: true ,
878
979
isPaired: true ,
0 commit comments