@@ -10,6 +10,7 @@ import 'package:file_testing/file_testing.dart';
1010import 'package:flutter_tools/src/artifacts.dart' ;
1111import 'package:flutter_tools/src/base/file_system.dart' ;
1212import 'package:flutter_tools/src/base/logger.dart' ;
13+ import 'package:flutter_tools/src/base/os.dart' ;
1314import 'package:flutter_tools/src/base/platform.dart' ;
1415import 'package:flutter_tools/src/base/version.dart' ;
1516import 'package:flutter_tools/src/build_info.dart' ;
@@ -79,6 +80,10 @@ final FakePlatform macPlatform = FakePlatform(
7980 environment: < String , String > {},
8081);
8182
83+ final FakeOperatingSystemUtils os = FakeOperatingSystemUtils (
84+ hostPlatform: HostPlatform .darwin_arm64,
85+ );
86+
8287void main () {
8388 late Artifacts artifacts;
8489 late String iosDeployPath;
@@ -153,6 +158,7 @@ void main() {
153158 ProcessManager : () => processManager,
154159 FileSystem : () => fileSystem,
155160 Logger : () => logger,
161+ OperatingSystemUtils : () => os,
156162 Platform : () => macPlatform,
157163 XcodeProjectInterpreter : () => FakeXcodeProjectInterpreter (buildSettings: const < String , String > {
158164 'WRAPPER_NAME' : 'My Super Awesome App.app' ,
@@ -243,6 +249,92 @@ void main() {
243249 ProcessManager : () => processManager,
244250 FileSystem : () => fileSystem,
245251 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+ ),
246338 Platform : () => macPlatform,
247339 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
248340 Xcode : () => xcode,
@@ -362,6 +454,7 @@ void main() {
362454 ProcessManager : () => FakeProcessManager .any (),
363455 FileSystem : () => fileSystem,
364456 Logger : () => logger,
457+ OperatingSystemUtils : () => os,
365458 Platform : () => macPlatform,
366459 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
367460 Xcode : () => xcode,
@@ -396,6 +489,7 @@ void main() {
396489 ProcessManager : () => FakeProcessManager .any (),
397490 FileSystem : () => fileSystem,
398491 Logger : () => logger,
492+ OperatingSystemUtils : () => os,
399493 Platform : () => macPlatform,
400494 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
401495 Xcode : () => xcode,
@@ -430,6 +524,7 @@ void main() {
430524 ProcessManager : () => FakeProcessManager .any (),
431525 FileSystem : () => fileSystem,
432526 Logger : () => logger,
527+ OperatingSystemUtils : () => os,
433528 Platform : () => macPlatform,
434529 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
435530 Xcode : () => xcode,
@@ -465,6 +560,7 @@ void main() {
465560 ProcessManager : () => FakeProcessManager .any (),
466561 FileSystem : () => fileSystem,
467562 Logger : () => logger,
563+ OperatingSystemUtils : () => os,
468564 Platform : () => macPlatform,
469565 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
470566 Xcode : () => xcode,
@@ -531,6 +627,7 @@ void main() {
531627 ProcessManager : () => FakeProcessManager .any (),
532628 FileSystem : () => fileSystem,
533629 Logger : () => logger,
630+ OperatingSystemUtils : () => os,
534631 Platform : () => macPlatform,
535632 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
536633 Xcode : () => xcode,
@@ -606,6 +703,7 @@ void main() {
606703 ProcessManager : () => FakeProcessManager .any (),
607704 FileSystem : () => fileSystem,
608705 Logger : () => logger,
706+ OperatingSystemUtils : () => os,
609707 Platform : () => macPlatform,
610708 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
611709 Xcode : () => xcode,
@@ -686,6 +784,7 @@ void main() {
686784 ProcessManager : () => FakeProcessManager .any (),
687785 FileSystem : () => fileSystem,
688786 Logger : () => logger,
787+ OperatingSystemUtils : () => os,
689788 Platform : () => macPlatform,
690789 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
691790 Xcode : () => xcode,
@@ -764,6 +863,7 @@ void main() {
764863 ProcessManager : () => FakeProcessManager .any (),
765864 FileSystem : () => fileSystem,
766865 Logger : () => logger,
866+ OperatingSystemUtils : () => os,
767867 Platform : () => macPlatform,
768868 XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
769869 Xcode : () => xcode,
@@ -839,6 +939,7 @@ IOSDevice setUpIOSDevice({
839939 bool isCoreDevice = false ,
840940 IOSCoreDeviceControl ? coreDeviceControl,
841941 FakeXcodeDebug ? xcodeDebug,
942+ DarwinArch cpuArchitecture = DarwinArch .arm64,
842943}) {
843944 artifacts ?? = Artifacts .test ();
844945 final Cache cache = Cache .test (
@@ -872,7 +973,7 @@ IOSDevice setUpIOSDevice({
872973 ),
873974 coreDeviceControl: coreDeviceControl ?? FakeIOSCoreDeviceControl (),
874975 xcodeDebug: xcodeDebug ?? FakeXcodeDebug (),
875- cpuArchitecture: DarwinArch .arm64 ,
976+ cpuArchitecture: cpuArchitecture ,
876977 connectionInterface: DeviceConnectionInterface .attached,
877978 isConnected: true ,
878979 isPaired: true ,
0 commit comments