-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[tool] Update tool to set macOS deployment target to 10.15. #6605
Changes from 1 commit
ee0aebe
abd3bc4
5d2c735
46a360c
cc6277f
45ea1cf
aef364d
0873843
c95ea9f
76c2152
c3d2276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This change is necessary for #6517.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,10 +61,19 @@ class CreateAllPluginsAppCommand extends PackageCommand { | |
| print(''); | ||
| } | ||
|
|
||
| await _genPubspecWithAllPlugins(); | ||
|
|
||
| /// Run `flutter pub get` to generate all native build files for macOS. | ||
| final int genNativeBuildFilesExitCode = await _genNativeBuildFiles(); | ||
| if (genNativeBuildFilesExitCode != 0) { | ||
| throw ToolExit(genNativeBuildFilesExitCode); | ||
|
||
| } | ||
|
|
||
| await Future.wait(<Future<void>>[ | ||
| _genPubspecWithAllPlugins(), | ||
| _updateAppGradle(), | ||
| _updateManifest(), | ||
| _updateMacosPodfile(), | ||
| _updateMacosPbxproj(), | ||
| ]); | ||
| } | ||
|
|
||
|
|
@@ -259,4 +268,75 @@ dev_dependencies:${_pubspecMapString(pubspec.devDependencies)} | |
|
|
||
| return buffer.toString(); | ||
| } | ||
|
|
||
| Future<int> _genNativeBuildFiles() async { | ||
|
||
| // Only run on macOS. | ||
| // Other platforms don't need generation of additional files. | ||
| if (!io.Platform.isMacOS) { | ||
|
||
| return 0; | ||
| } | ||
|
|
||
| final io.ProcessResult result = io.Process.runSync( | ||
|
||
| flutterCommand, | ||
| <String>[ | ||
| 'pub', | ||
| 'get', | ||
| ], | ||
| workingDirectory: _appDirectory.path, | ||
| ); | ||
|
|
||
| print(result.stdout); | ||
| print(result.stderr); | ||
| return result.exitCode; | ||
| } | ||
|
|
||
| Future<void> _updateMacosPodfile() async { | ||
| // Only change the macOS deployment target if the host platform is macOS. | ||
stuartmorgan-g marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!io.Platform.isMacOS) { | ||
| return; | ||
| } | ||
|
|
||
| final File podfileFile = | ||
| app.platformDirectory(FlutterPlatform.macos).childFile('Podfile'); | ||
| if (!podfileFile.existsSync()) { | ||
| throw ToolExit(64); | ||
|
||
| } | ||
|
|
||
| final StringBuffer newPodfile = StringBuffer(); | ||
| for (final String line in podfileFile.readAsLinesSync()) { | ||
| if (line.contains('platform :osx')) { | ||
| // macOS 10.15 is required by in_app_purchase. | ||
| newPodfile.writeln("platform :osx, '10.15'"); | ||
| } else { | ||
| newPodfile.writeln(line); | ||
| } | ||
| } | ||
| podfileFile.writeAsStringSync(newPodfile.toString()); | ||
| } | ||
|
|
||
| Future<void> _updateMacosPbxproj() async { | ||
| // Only change the macOS deployment target if the host platform is macOS. | ||
|
||
| if (!io.Platform.isMacOS) { | ||
| return; | ||
| } | ||
|
|
||
| final File pbxprojFile = app | ||
| .platformDirectory(FlutterPlatform.macos) | ||
| .childDirectory('Runner.xcodeproj') | ||
| .childFile('project.pbxproj'); | ||
| if (!pbxprojFile.existsSync()) { | ||
| throw ToolExit(64); | ||
| } | ||
|
|
||
| final StringBuffer newPbxproj = StringBuffer(); | ||
| for (final String line in pbxprojFile.readAsLinesSync()) { | ||
| if (line.contains('MACOSX_DEPLOYMENT_TARGET')) { | ||
| // macOS 10.15 is required by in_app_purchase. | ||
| newPbxproj.writeln(' MACOSX_DEPLOYMENT_TARGET = 10.15;'); | ||
| } else { | ||
| newPbxproj.writeln(line); | ||
| } | ||
| } | ||
| pbxprojFile.writeAsStringSync(newPbxproj.toString()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove the "for macOS" here since it's all platform (even if we only happen to be using it for macOS right now).