@@ -61,10 +61,19 @@ class CreateAllPluginsAppCommand extends PackageCommand {
61
61
print ('' );
62
62
}
63
63
64
+ await _genPubspecWithAllPlugins ();
65
+
66
+ /// Run `flutter pub get` to generate all native build files for macOS.
67
+ final int genNativeBuildFilesExitCode = await _genNativeBuildFiles ();
68
+ if (genNativeBuildFilesExitCode != 0 ) {
69
+ throw ToolExit (genNativeBuildFilesExitCode);
70
+ }
71
+
64
72
await Future .wait (< Future <void >> [
65
- _genPubspecWithAllPlugins (),
66
73
_updateAppGradle (),
67
74
_updateManifest (),
75
+ _updateMacosPodfile (),
76
+ _updateMacosPbxproj (),
68
77
]);
69
78
}
70
79
@@ -259,4 +268,75 @@ dev_dependencies:${_pubspecMapString(pubspec.devDependencies)}
259
268
260
269
return buffer.toString ();
261
270
}
271
+
272
+ Future <int > _genNativeBuildFiles () async {
273
+ // Only run on macOS.
274
+ // Other platforms don't need generation of additional files.
275
+ if (! io.Platform .isMacOS) {
276
+ return 0 ;
277
+ }
278
+
279
+ final io.ProcessResult result = io.Process .runSync (
280
+ flutterCommand,
281
+ < String > [
282
+ 'pub' ,
283
+ 'get' ,
284
+ ],
285
+ workingDirectory: _appDirectory.path,
286
+ );
287
+
288
+ print (result.stdout);
289
+ print (result.stderr);
290
+ return result.exitCode;
291
+ }
292
+
293
+ Future <void > _updateMacosPodfile () async {
294
+ // Only change the macOS deployment target if the host platform is macOS.
295
+ if (! io.Platform .isMacOS) {
296
+ return ;
297
+ }
298
+
299
+ final File podfileFile =
300
+ app.platformDirectory (FlutterPlatform .macos).childFile ('Podfile' );
301
+ if (! podfileFile.existsSync ()) {
302
+ throw ToolExit (64 );
303
+ }
304
+
305
+ final StringBuffer newPodfile = StringBuffer ();
306
+ for (final String line in podfileFile.readAsLinesSync ()) {
307
+ if (line.contains ('platform :osx' )) {
308
+ // macOS 10.15 is required by in_app_purchase.
309
+ newPodfile.writeln ("platform :osx, '10.15'" );
310
+ } else {
311
+ newPodfile.writeln (line);
312
+ }
313
+ }
314
+ podfileFile.writeAsStringSync (newPodfile.toString ());
315
+ }
316
+
317
+ Future <void > _updateMacosPbxproj () async {
318
+ // Only change the macOS deployment target if the host platform is macOS.
319
+ if (! io.Platform .isMacOS) {
320
+ return ;
321
+ }
322
+
323
+ final File pbxprojFile = app
324
+ .platformDirectory (FlutterPlatform .macos)
325
+ .childDirectory ('Runner.xcodeproj' )
326
+ .childFile ('project.pbxproj' );
327
+ if (! pbxprojFile.existsSync ()) {
328
+ throw ToolExit (64 );
329
+ }
330
+
331
+ final StringBuffer newPbxproj = StringBuffer ();
332
+ for (final String line in pbxprojFile.readAsLinesSync ()) {
333
+ if (line.contains ('MACOSX_DEPLOYMENT_TARGET' )) {
334
+ // macOS 10.15 is required by in_app_purchase.
335
+ newPbxproj.writeln (' MACOSX_DEPLOYMENT_TARGET = 10.15;' );
336
+ } else {
337
+ newPbxproj.writeln (line);
338
+ }
339
+ }
340
+ pbxprojFile.writeAsStringSync (newPbxproj.toString ());
341
+ }
262
342
}
0 commit comments