From 7674d7296edb836c3f656c4ccd868fb229d3e90d Mon Sep 17 00:00:00 2001 From: birros Date: Sun, 17 Aug 2025 17:59:44 +0200 Subject: [PATCH] flutter335: fix macos build Fix for macOS build issue in Flutter >= 3.35 Since version 3.35, the behavior of macos_assemble.sh and xcode_backend.sh is almost identical. This caused the same error for macOS that previously occurred for iOS. Derived from the iOS patch: ./fix-ios-build-xcode-backend-sh.patch Example error: ``` $ flutter run -d macos Launching lib/main.dart on macOS in debug mode... Target debug_unpack_macos failed: Error: Flutter failed to create a directory at "//XXXX-flutter-3.35.1-unwrapped/bin/cache/artifacts". Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user. Failed to copy Flutter framework. ** BUILD FAILED ** ``` --- .../fix-macos-build-macos-assemble-sh.patch | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 pkgs/development/compilers/flutter/versions/3_35/patches/fix-macos-build-macos-assemble-sh.patch diff --git a/pkgs/development/compilers/flutter/versions/3_35/patches/fix-macos-build-macos-assemble-sh.patch b/pkgs/development/compilers/flutter/versions/3_35/patches/fix-macos-build-macos-assemble-sh.patch new file mode 100644 index 000000000000..312ec3a5c1ba --- /dev/null +++ b/pkgs/development/compilers/flutter/versions/3_35/patches/fix-macos-build-macos-assemble-sh.patch @@ -0,0 +1,59 @@ +Fix for macOS build issue in Flutter >= 3.35 + +Since version 3.35, the behavior of macos_assemble.sh and xcode_backend.sh +is almost identical. This caused the same error for macOS that previously +occurred for iOS. + +Derived from the iOS patch: ./fix-ios-build-xcode-backend-sh.patch + +Example error: +``` +$ flutter run -d macos +Launching lib/main.dart on macOS in debug mode... +Target debug_unpack_macos failed: Error: Flutter failed to create a directory at "//XXXX-flutter-3.35.1-unwrapped/bin/cache/artifacts". +Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user. +Failed to copy Flutter framework. +** BUILD FAILED ** +``` + +--- + +diff --git a/packages/flutter_tools/bin/macos_assemble.sh b/packages/flutter_tools/bin/macos_assemble.sh +index 28acf8842..d0f2923df 100644 +--- a/packages/flutter_tools/bin/macos_assemble.sh ++++ b/packages/flutter_tools/bin/macos_assemble.sh +@@ -13,29 +13,13 @@ + # exit on error, or usage of unset var + set -euo pipefail + +-# Needed because if it is set, cd may print the path it changed to. +-unset CDPATH +- +-function follow_links() ( +- cd -P "$(dirname -- "$1")" +- file="$PWD/$(basename -- "$1")" +- while [[ -h "$file" ]]; do +- cd -P "$(dirname -- "$file")" +- file="$(readlink -- "$file")" +- cd -P "$(dirname -- "$file")" +- file="$PWD/$(basename -- "$file")" +- done +- echo "$file" +-) +- +-PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")" +-BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" +-FLUTTER_ROOT="$BIN_DIR/../../.." +-DART="$FLUTTER_ROOT/bin/dart" ++# Run `dart ./xcode_backend.dart` with the dart from $FLUTTER_ROOT. ++dart="${FLUTTER_ROOT}/bin/dart" ++xcode_backend_dart="$(dirname "${BASH_SOURCE[0]}")/xcode_backend.dart" + + # Main entry point. + if [[ $# == 0 ]]; then +- "$DART" "$BIN_DIR/xcode_backend.dart" "build" "macos" ++ exec "${dart}" "${xcode_backend_dart}" "build" "macos" + else +- "$DART" "$BIN_DIR/xcode_backend.dart" "$@" "macos" ++ exec "${dart}" "${xcode_backend_dart}" "$@" "macos" + fi