FLUTTER_BUILD_DIR environment variable - default to 'build' on macos#180251
FLUTTER_BUILD_DIR environment variable - default to 'build' on macos#180251WillCallahan wants to merge 4 commits into
Conversation
jmagman
left a comment
There was a problem hiding this comment.
Thanks for your contribution @WillCallahan!
FLUTTER_BUILD_DIR should always be set in the Generated.xcconfig, for macOS as well as iOS. Despite the path,
actually is already called for macOS:
It would be better to diagnose why the xcconfig isn't hooked up in the project. For a newly flutter created project, it is. It sets other things beside FLUTTER_BUILD_DIR, so this is just hiding a larger problem.
Do you have flavors set up? Are the configurations set up correctly in Xcode?
If it's not set, it may be appropriate to fail with an actionable error message, instead of continuing in a bad state as this PR does.
flutter/packages/flutter_tools/bin/xcode_backend.dart
Lines 239 to 251 in c00f050
|
Ahh, I see; I performed a flutter upgrade and am missing this configuration. I will update this code so that we get a more descriptive exception message with how to fix it. |
That shouldn't be impacted by a If we want to do this, it should be to hard-fail if an expected variable from the Generated.xcconfig isn't found, not do a soft fallback for only one of the variables, and print instructions or a link to instructions for how to hook it back up in the Xcode project. |
|
@WillCallahan From Triage: We're putting this in draft. Please feel free to mark as ready for review when you want us to look at it again! |
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Hey there @WillCallahan, is this a change you would like to continue working on? |
|
I can get this across the finish line if @WillCallahan isn't planning to |
|
Thanks @Hari-07! I am going to close this since we have not heard back. Please feel free to pick it up if you would like! |
This PR fixes an issue where the
FLUTTER_BUILD_DIRenvironment variable is not defaulted for macOS builds, which can cause build failures.When building a Flutter app for macOS, parts of the build process may rely on the
FLUTTER_BUILD_DIRenvironment variable. If this variable is not set, the build can fail with a null-pointer exception. This change ensures thatFLUTTER_BUILD_DIRis always defaulted to "build" if it is not set. This is done by creating a mutable copy of the environment in thexcode_backend.dartscript and setting the default value there.This change brings the macOS build behavior in line with the iOS build process, which already has similar logic. The following files provide evidence that "build" is the correct default:
getBuildDirectory(), which defaults to "build" (see https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_info.dart#L863-L875).FLUTTER_BUILD_DIR=build.Issues
FLUTTER_BUILD_DIRenvironment variable isn't configured. #140845. Both a warning message is logged and a default value is used.Pre-launch Checklist
///).