@@ -14,8 +14,13 @@ import 'base/logger.dart';
1414import 'base/utils.dart' ;
1515import 'convert.dart' ;
1616import 'device.dart' ;
17+ import 'ios/xcodeproj.dart' ;
18+ import 'project.dart' ;
1719import 'version.dart' ;
1820
21+ const String kResultType = 'type' ;
22+ const String kResultTypeSuccess = 'Success' ;
23+
1924const String kGetSkSLsMethod = '_flutter.getSkSLs' ;
2025const String kSetAssetBundlePathMethod = '_flutter.setAssetBundlePath' ;
2126const String kFlushUIThreadTasksMethod = '_flutter.flushUIThreadTasks' ;
@@ -165,6 +170,7 @@ typedef VMServiceConnector = Future<FlutterVmService> Function(Uri httpUri, {
165170 Restart ? restart,
166171 CompileExpression ? compileExpression,
167172 GetSkSLMethod ? getSkSLMethod,
173+ FlutterProject ? flutterProject,
168174 PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
169175 io.CompressionOptions compression,
170176 Device ? device,
@@ -175,15 +181,16 @@ typedef VMServiceConnector = Future<FlutterVmService> Function(Uri httpUri, {
175181/// callbacks.
176182///
177183/// All parameters besides [vmService] may be null.
178- Future <vm_service.VmService > setUpVmService (
184+ Future <vm_service.VmService > setUpVmService ({
179185 ReloadSources ? reloadSources,
180186 Restart ? restart,
181187 CompileExpression ? compileExpression,
182188 Device ? device,
183189 GetSkSLMethod ? skSLMethod,
190+ FlutterProject ? flutterProject,
184191 PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
185- vm_service.VmService vmService
186- ) async {
192+ required vm_service.VmService vmService,
193+ } ) async {
187194 // Each service registration requires a request to the attached VM service. Since the
188195 // order of these requests does not matter, store each future in a list and await
189196 // all at the end of this method.
@@ -198,7 +205,7 @@ Future<vm_service.VmService> setUpVmService(
198205
199206 return < String , Object > {
200207 'result' : < String , Object > {
201- 'type' : 'Success' ,
208+ kResultType : kResultTypeSuccess ,
202209 },
203210 };
204211 });
@@ -211,7 +218,7 @@ Future<vm_service.VmService> setUpVmService(
211218 await restart (pause: pause);
212219 return < String , Object > {
213220 'result' : < String , Object > {
214- 'type' : 'Success' ,
221+ kResultType : kResultTypeSuccess ,
215222 },
216223 };
217224 });
@@ -225,7 +232,7 @@ Future<vm_service.VmService> setUpVmService(
225232 versionJson['engineRevisionShort' ] = version.engineRevisionShort;
226233 return < String , Object > {
227234 'result' : < String , Object > {
228- 'type' : 'Success' ,
235+ kResultType : kResultTypeSuccess ,
229236 ...versionJson,
230237 },
231238 };
@@ -246,7 +253,7 @@ Future<vm_service.VmService> setUpVmService(
246253 expression, definitions, typeDefinitions, libraryUri, klass,
247254 isStatic);
248255 return < String , Object > {
249- 'type' : 'Success' ,
256+ kResultType : kResultTypeSuccess ,
250257 'result' : < String , String > {'kernelBytes' : kernelBytesBase64},
251258 };
252259 });
@@ -257,7 +264,7 @@ Future<vm_service.VmService> setUpVmService(
257264 final MemoryInfo result = await device.queryMemoryInfo ();
258265 return < String , Object > {
259266 'result' : < String , Object > {
260- 'type' : 'Success' ,
267+ kResultType : kResultTypeSuccess ,
261268 ...result.toJson (),
262269 },
263270 };
@@ -270,19 +277,44 @@ Future<vm_service.VmService> setUpVmService(
270277 if (filename == null ) {
271278 return < String , Object > {
272279 'result' : < String , Object > {
273- 'type' : 'Success' ,
280+ kResultType : kResultTypeSuccess ,
274281 },
275282 };
276283 }
277284 return < String , Object > {
278285 'result' : < String , Object > {
279- 'type' : 'Success' ,
286+ kResultType : kResultTypeSuccess ,
280287 'filename' : filename,
281288 },
282289 };
283290 });
284291 registrationRequests.add (vmService.registerService ('flutterGetSkSL' , 'Flutter Tools' ));
285292 }
293+
294+ if (flutterProject != null ) {
295+ vmService.registerServiceCallback ('flutterGetIOSBuildOptions' , (Map <String , Object ?> params) async {
296+ final XcodeProjectInfo ? info = await flutterProject.ios.projectInfo ();
297+ if (info == null ) {
298+ return < String , Object > {
299+ 'result' : < String , Object > {
300+ kResultType: kResultTypeSuccess,
301+ },
302+ };
303+ }
304+ return < String , Object > {
305+ 'result' : < String , Object > {
306+ kResultType: kResultTypeSuccess,
307+ 'targets' : info.targets,
308+ 'schemes' : info.schemes,
309+ 'buildConfigurations' : info.buildConfigurations,
310+ },
311+ };
312+ });
313+ registrationRequests.add (
314+ vmService.registerService ('flutterGetIOSBuildOptions' , 'Flutter Tools' ),
315+ );
316+ }
317+
286318 if (printStructuredErrorLogMethod != null ) {
287319 vmService.onExtensionEvent.listen (printStructuredErrorLogMethod);
288320 registrationRequests.add (vmService
@@ -319,15 +351,16 @@ Future<vm_service.VmService> setUpVmService(
319351/// See: https://github.com/dart-lang/sdk/commit/df8bf384eb815cf38450cb50a0f4b62230fba217
320352Future <FlutterVmService > connectToVmService (
321353 Uri httpUri, {
322- ReloadSources ? reloadSources,
323- Restart ? restart,
324- CompileExpression ? compileExpression,
325- GetSkSLMethod ? getSkSLMethod,
326- PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
327- io.CompressionOptions compression = io.CompressionOptions .compressionDefault,
328- Device ? device,
329- required Logger logger,
330- }) async {
354+ ReloadSources ? reloadSources,
355+ Restart ? restart,
356+ CompileExpression ? compileExpression,
357+ GetSkSLMethod ? getSkSLMethod,
358+ FlutterProject ? flutterProject,
359+ PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
360+ io.CompressionOptions compression = io.CompressionOptions .compressionDefault,
361+ Device ? device,
362+ required Logger logger,
363+ }) async {
331364 final VMServiceConnector connector = context.get <VMServiceConnector >() ?? _connect;
332365 return connector (httpUri,
333366 reloadSources: reloadSources,
@@ -336,6 +369,7 @@ Future<FlutterVmService> connectToVmService(
336369 compression: compression,
337370 device: device,
338371 getSkSLMethod: getSkSLMethod,
372+ flutterProject: flutterProject,
339373 printStructuredErrorLogMethod: printStructuredErrorLogMethod,
340374 logger: logger,
341375 );
@@ -362,6 +396,7 @@ Future<FlutterVmService> _connect(
362396 Restart ? restart,
363397 CompileExpression ? compileExpression,
364398 GetSkSLMethod ? getSkSLMethod,
399+ FlutterProject ? flutterProject,
365400 PrintStructuredErrorLogMethod ? printStructuredErrorLogMethod,
366401 io.CompressionOptions compression = io.CompressionOptions .compressionDefault,
367402 Device ? device,
@@ -373,13 +408,14 @@ Future<FlutterVmService> _connect(
373408 );
374409
375410 final vm_service.VmService service = await setUpVmService (
376- reloadSources,
377- restart,
378- compileExpression,
379- device,
380- getSkSLMethod,
381- printStructuredErrorLogMethod,
382- delegateService,
411+ reloadSources: reloadSources,
412+ restart: restart,
413+ compileExpression: compileExpression,
414+ device: device,
415+ skSLMethod: getSkSLMethod,
416+ flutterProject: flutterProject,
417+ printStructuredErrorLogMethod: printStructuredErrorLogMethod,
418+ vmService: delegateService,
383419 );
384420
385421 // This call is to ensure we are able to establish a connection instead of
0 commit comments