Skip to content

Commit 114185f

Browse files
authored
Pass 'build ios' device ID into xcodebuild (flutter#96669)
1 parent 25b2edb commit 114185f

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

packages/flutter_tools/lib/src/commands/build_ios.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
269269
codesign: shouldCodesign,
270270
configOnly: configOnly,
271271
buildAction: xcodeBuildAction,
272+
deviceID: globals.deviceManager?.specifiedDeviceId,
272273
);
273274

274275
if (!result.success) {

packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ void main() {
112112

113113
// Creates a FakeCommand for the xcodebuild call to build the app
114114
// in the given configuration.
115-
FakeCommand _setUpFakeXcodeBuildHandler({ bool verbose = false, bool simulator = false, int exitCode = 0, void Function() onRun }) {
115+
FakeCommand _setUpFakeXcodeBuildHandler({
116+
bool verbose = false,
117+
bool simulator = false,
118+
String deviceId,
119+
int exitCode = 0,
120+
void Function() onRun,
121+
}) {
116122
return FakeCommand(
117123
command: <String>[
118124
'xcrun',
@@ -132,10 +138,16 @@ void main() {
132138
'-sdk',
133139
if (simulator) ...<String>[
134140
'iphonesimulator',
141+
] else ...<String>[
142+
'iphoneos',
143+
],
144+
if (deviceId != null) ...<String>[
145+
'-destination',
146+
'id=$deviceId',
147+
] else if (simulator) ...<String>[
135148
'-destination',
136149
'generic/platform=iOS Simulator',
137150
] else ...<String>[
138-
'iphoneos',
139151
'-destination',
140152
'generic/platform=iOS',
141153
],
@@ -220,6 +232,27 @@ void main() {
220232
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
221233
});
222234

235+
testUsingContext('ios build invokes xcode build with device ID', () async {
236+
final BuildCommand command = BuildCommand();
237+
_createMinimalMockProjectFiles();
238+
239+
await createTestCommandRunner(command).run(
240+
const <String>['build', 'ios', '--no-pub', '--device-id', '1234']
241+
);
242+
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
243+
}, overrides: <Type, Generator>{
244+
FileSystem: () => fileSystem,
245+
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
246+
xattrCommand,
247+
_setUpFakeXcodeBuildHandler(deviceId: '1234', onRun: () {
248+
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
249+
}),
250+
_setUpRsyncCommand(),
251+
]),
252+
Platform: () => macosPlatform,
253+
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
254+
});
255+
223256
testUsingContext('ios simulator build invokes xcode build', () async {
224257
final BuildCommand command = BuildCommand();
225258
_createMinimalMockProjectFiles();

0 commit comments

Comments
 (0)