Restructure macOS project files (#33608)
Rather than macos/Flutter containing a mixture of files that should and
shouldn't be checked in, create clear locations for:
- Files that are "owned" by Flutter, but should be checked in
(Flutter/). This will contain files like the top-level Flutter
xcconfigs, generated plugin registrants, etc.
- Files that are generated by Flutter on the fly, and should not be
checked in (Flutter/ephemeral/). This will contain Flutter SDK caches,
the generated xcconfig, etc.
Also adds Flutter-owned Debug and Release xcconfig variants, in
preparation for PodSpec tooling.
diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart
index 46cec9b..970d9ee 100644
--- a/packages/flutter_tools/lib/src/project.dart
+++ b/packages/flutter_tools/lib/src/project.dart
@@ -580,27 +580,38 @@
static const String _hostAppBundleName = 'Runner';
- bool existsSync() => project.directory.childDirectory('macos').existsSync();
+ bool existsSync() => _macOSDirectory.existsSync();
- Directory get _editableDirectory => project.directory.childDirectory('macos');
+ Directory get _macOSDirectory => project.directory.childDirectory('macos');
- Directory get _cacheDirectory => _editableDirectory.childDirectory('Flutter');
+ /// The directory in the project that is managed by Flutter. As much as
+ /// possible, files that are edited by Flutter tooling after initial project
+ /// creation should live here.
+ Directory get managedDirectory => _macOSDirectory.childDirectory('Flutter');
+
+ /// The subdirectory of [managedDirectory] that contains files that are
+ /// generated on the fly. All generated files that are not intended to be
+ /// checked in should live here.
+ Directory get ephemeralDirectory => managedDirectory.childDirectory('ephemeral');
/// Contains definitions for FLUTTER_ROOT, LOCAL_ENGINE, and more flags for
/// the Xcode build.
- File get generatedXcodePropertiesFile => _cacheDirectory.childFile('Generated.xcconfig');
+ File get generatedXcodePropertiesFile => ephemeralDirectory.childFile('Flutter-Generated.xcconfig');
+
+ /// The Flutter-managed Xcode config file for [mode].
+ File xcodeConfigFor(String mode) => managedDirectory.childFile('Flutter-$mode.xcconfig');
/// The Xcode project file.
- Directory get xcodeProject => _editableDirectory.childDirectory('$_hostAppBundleName.xcodeproj');
+ Directory get xcodeProject => _macOSDirectory.childDirectory('$_hostAppBundleName.xcodeproj');
/// The Xcode workspace file.
- Directory get xcodeWorkspace => _editableDirectory.childDirectory('$_hostAppBundleName.xcworkspace');
+ Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppBundleName.xcworkspace');
/// The file where the Xcode build will write the name of the built app.
///
/// Ideally this will be replaced in the future with inspection of the Runner
/// scheme's target.
- File get nameFile => _cacheDirectory.childFile('.app_filename');
+ File get nameFile => ephemeralDirectory.childFile('.app_filename');
}
/// The Windows sub project