@@ -112,7 +112,13 @@ void main() {
112
112
113
113
// Creates a FakeCommand for the xcodebuild call to build the app
114
114
// 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
+ }) {
116
122
return FakeCommand (
117
123
command: < String > [
118
124
'xcrun' ,
@@ -132,10 +138,16 @@ void main() {
132
138
'-sdk' ,
133
139
if (simulator) ...< String > [
134
140
'iphonesimulator' ,
141
+ ] else ...< String > [
142
+ 'iphoneos' ,
143
+ ],
144
+ if (deviceId != null ) ...< String > [
145
+ '-destination' ,
146
+ 'id=$deviceId ' ,
147
+ ] else if (simulator) ...< String > [
135
148
'-destination' ,
136
149
'generic/platform=iOS Simulator' ,
137
150
] else ...< String > [
138
- 'iphoneos' ,
139
151
'-destination' ,
140
152
'generic/platform=iOS' ,
141
153
],
@@ -220,6 +232,27 @@ void main() {
220
232
XcodeProjectInterpreter : () => FakeXcodeProjectInterpreterWithBuildSettings (),
221
233
});
222
234
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
+
223
256
testUsingContext ('ios simulator build invokes xcode build' , () async {
224
257
final BuildCommand command = BuildCommand ();
225
258
_createMinimalMockProjectFiles ();
0 commit comments