Unverified Commit 114185f6 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Pass 'build ios' device ID into xcodebuild (#96669)

parent 25b2edbd
...@@ -269,6 +269,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand { ...@@ -269,6 +269,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
codesign: shouldCodesign, codesign: shouldCodesign,
configOnly: configOnly, configOnly: configOnly,
buildAction: xcodeBuildAction, buildAction: xcodeBuildAction,
deviceID: globals.deviceManager?.specifiedDeviceId,
); );
if (!result.success) { if (!result.success) {
......
...@@ -112,7 +112,13 @@ void main() { ...@@ -112,7 +112,13 @@ void main() {
// Creates a FakeCommand for the xcodebuild call to build the app // Creates a FakeCommand for the xcodebuild call to build the app
// in the given configuration. // in the given configuration.
FakeCommand _setUpFakeXcodeBuildHandler({ bool verbose = false, bool simulator = false, int exitCode = 0, void Function() onRun }) { FakeCommand _setUpFakeXcodeBuildHandler({
bool verbose = false,
bool simulator = false,
String deviceId,
int exitCode = 0,
void Function() onRun,
}) {
return FakeCommand( return FakeCommand(
command: <String>[ command: <String>[
'xcrun', 'xcrun',
...@@ -132,10 +138,16 @@ void main() { ...@@ -132,10 +138,16 @@ void main() {
'-sdk', '-sdk',
if (simulator) ...<String>[ if (simulator) ...<String>[
'iphonesimulator', 'iphonesimulator',
] else ...<String>[
'iphoneos',
],
if (deviceId != null) ...<String>[
'-destination',
'id=$deviceId',
] else if (simulator) ...<String>[
'-destination', '-destination',
'generic/platform=iOS Simulator', 'generic/platform=iOS Simulator',
] else ...<String>[ ] else ...<String>[
'iphoneos',
'-destination', '-destination',
'generic/platform=iOS', 'generic/platform=iOS',
], ],
...@@ -220,6 +232,27 @@ void main() { ...@@ -220,6 +232,27 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
}); });
testUsingContext('ios build invokes xcode build with device ID', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();
await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '--device-id', '1234']
);
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand,
_setUpFakeXcodeBuildHandler(deviceId: '1234', onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
}),
_setUpRsyncCommand(),
]),
Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('ios simulator build invokes xcode build', () async { testUsingContext('ios simulator build invokes xcode build', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); _createMinimalMockProjectFiles();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment