Adjust macOS build flow (#32538)
- Removes SYMROOT from the Generated.xcconfig. Having it causes current
versions of Xcode to switch the project's build output to "Legacy",
which causes anything not overridden to use a project-relative build
directory instead of a shared directory in DerivedData, breaking
anything with subprojects that it depends on.
This means that `flutter run` and builds from Xcode will use
completely different build directories, but that each should be
internally consistent.
- Moves the FlutterMacOS.framework to $SRCROOT/Flutter. This is
consistent with the approach we're moving to for all desktop
platforms, and avoids issues finding it now that SYMROOT doesn't match
for the two different build modes.
Fixes #32494
diff --git a/packages/flutter_tools/bin/macos_build_flutter_assets.sh b/packages/flutter_tools/bin/macos_build_flutter_assets.sh
index b28bc7b..9323fee 100755
--- a/packages/flutter_tools/bin/macos_build_flutter_assets.sh
+++ b/packages/flutter_tools/bin/macos_build_flutter_assets.sh
@@ -41,7 +41,7 @@
# Copy the framework and handle local engine builds.
framework_name="FlutterMacOS.framework"
-derived_dir="${SOURCE_ROOT}/../build/macos/Build/Products/flutter_framework"
+derived_dir="${SOURCE_ROOT}/Flutter"
framework_path="${FLUTTER_ROOT}/bin/cache/artifacts/engine/darwin-x64"
flutter_framework="${framework_path}/${framework_name}"
diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
index d4441df..5b7a91f 100644
--- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -37,8 +37,7 @@
/// useMacOSConfig: Optional parameter that controls whether we use the macOS
/// project file instead. Defaults to false.
///
-/// symrootOverride: Optional parameter to specifify the symroot instead of
-/// the default relative path.
+/// setSymroot: Optional parameter to control whether to set SYMROOT.
///
/// targetOverride: Optional parameter, if null or unspecified the default value
/// from xcode_backend.sh is used 'lib/main.dart'.
@@ -47,7 +46,7 @@
@required BuildInfo buildInfo,
String targetOverride,
bool useMacOSConfig = false,
- String symrootOverride,
+ bool setSymroot = true,
}) async {
final StringBuffer localsBuffer = StringBuffer();
@@ -66,13 +65,8 @@
// The build outputs directory, relative to FLUTTER_APPLICATION_PATH.
localsBuffer.writeln('FLUTTER_BUILD_DIR=${getBuildDirectory()}');
- final String buildDirectory = useMacOSConfig
- ? getMacOSBuildDirectory()
- : getIosBuildDirectory();
- if (symrootOverride != null) {
- localsBuffer.writeln('SYMROOT=$symrootOverride');
- } else {
- localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../$buildDirectory');
+ if (setSymroot) {
+ localsBuffer.writeln('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
}
if (!project.isModule) {
diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart
index 5d32089..c456f39 100644
--- a/packages/flutter_tools/lib/src/macos/build_macos.dart
+++ b/packages/flutter_tools/lib/src/macos/build_macos.dart
@@ -18,7 +18,6 @@
// TODO(jonahwilliams): refactor to share code with the existing iOS code.
Future<void> buildMacOS(FlutterProject flutterProject, BuildInfo buildInfo) async {
final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory());
- final String symrootOverride = fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products');
if (!flutterBuildDir.existsSync()) {
flutterBuildDir.createSync(recursive: true);
}
@@ -27,7 +26,7 @@
project: flutterProject,
buildInfo: buildInfo,
useMacOSConfig: true,
- symrootOverride: symrootOverride,
+ setSymroot: false,
);
// Set debug or release mode.
String config = 'Debug';
@@ -44,7 +43,7 @@
'-scheme', 'Runner',
'-derivedDataPath', flutterBuildDir.absolute.path,
'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
- 'SYMROOT=$symrootOverride',
+ 'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
], runInShell: true);
final Status status = logger.startProgress(
'Building macOS application...',