New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean Xcode workspace during flutter clean #38992
Conversation
Works as expected. Do you want to add the |
Codecov Report
@@ Coverage Diff @@
## master #38992 +/- ##
==========================================
+ Coverage 55.75% 56.31% +0.56%
==========================================
Files 195 195
Lines 18303 18321 +18
==========================================
+ Hits 10204 10318 +114
+ Misses 8099 8003 -96
Continue to review full report at Codecov.
|
Sounds great, I think I assumed that was already happening actually. Worth noting is that when I named that, I didn't know that iOS/Android add-to-app had used the same term for something different, which may be confusing in contexts like this one. I should maybe rename it.
Will do a bit later today. |
final String path = file.path; | ||
printStatus("Deleting '$path${fs.path.separator}'."); | ||
Future<void> _cleanXcode(XcodeBasedProject xcodeProject) async { | ||
if (xcodeProject.existsSync()) { |
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.
Could reduce the nesting here with an early return.
if (xcodeProject.existsSync()) { | |
if (!xcodeProject.existsSync()) { | |
return; | |
} |
} | ||
|
||
@visibleForTesting | ||
void deleteFile(FileSystemEntity file) { | ||
if (file.existsSync()) { |
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.
Also here
// Clean Xcode to remove intermediate DerivedData artifacts. | ||
// Do this before removing ephemeral directory, which would delete the xcworkspace. | ||
final FlutterProject flutterProject = FlutterProject.current(); | ||
if (xcode.isInstalledAndMeetsVersionCheck) { |
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.
I don't think this check can handle being run on windows host machines, you might need a platform guard as well.
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.
Maybe getCurrentHostPlatform() == HostPlatform.darwin_x64
needs to be added to isInstalledAndMeetsVersionCheck instead?
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.
Sounds reasonable. You can use platform.isMacOS
for this check. It is an injected value so that is still testable
if (!file.existsSync()) { | ||
return; | ||
} | ||
final Status deletionStatus = logger.startProgress('Deleting ${file.basename}...', timeout: timeoutConfiguration.fastOperation); |
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.
It seemed surprising in use that this showed the progress spinner; it was very fast.
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace; | ||
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path); | ||
for (String scheme in projectInfo.schemes) { | ||
xcodeStatus = logger.startProgress('Cleaning Xcode workspace for scheme $scheme...', timeout: timeoutConfiguration.slowOperation); |
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.
I'm seeing no newlines after the spinners, which made the output really weird:
$ flutter clean
Cleaning Xcode workspace for scheme Build Flutter Bundle... ⣽Deleting build... 105ms
Deleting ephemeral... 4ms
⣻$
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.
I just pushed a fix for the progress part, but I suspect the workspace clean is failing. Can you try again with flutter clean -v
?
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.
This is the workspace section of the -v
output (using the FDE example app; full paths elided):
[ +169 ms] Cleaning Xcode workspace...
[ +5 ms] executing: [.../example/macos/] /usr/bin/xcodebuild -list
[+1031 ms] Information about project "Runner":
Targets:
Runner
Build Flutter Bundle
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then
"Release" is used.
Schemes:
Build Flutter Bundle
Runner
[ +2 ms] executing: [.../example/] /usr/bin/xcodebuild -workspace
.../example/macos/Runner.xcworkspace -scheme Build Flutter Bundle -quiet clean
[+1082 ms] Exit code 0 from: /usr/bin/xcodebuild -workspace
.../example/macos/Runner.xcworkspace -scheme Build Flutter Bundle -quiet clean
[ +1 ms] executing: [.../example/] /usr/bin/xcodebuild -workspace
.../example/macos/Runner.xcworkspace -scheme Runner -quiet clean
[+1088 ms] Exit code 0 from: /usr/bin/xcodebuild -workspace
.../example/macos/Runner.xcworkspace -scheme Runner -quiet clean
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.
That looks correct. Do you still see the lack of newlines without -v
?
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.
No, formatting without -v looked good in that test.
…ove dead method instead of migrating
@override | ||
void printNoConnectedDevices() { | ||
super.printNoConnectedDevices(); | ||
if (getCurrentHostPlatform() == HostPlatform.darwin_x64 && |
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.
I was about to migrate this if statement but I realized it was dead code as of #35084.
(That was actually a comment from @stuartmorgan not me!) I think people wouldn't expect to have to run |
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.
LGTM once @stuartmorgan's concerns are addressed.
Sorry, somehow I frequently hit "Edit" instead of "Quote Reply". Usually I notice before submitting, but apparently not always.
But |
I was thinking of the case where they I could add it and we can see if people complain. @xster What do you think? |
Actually I filed #39003 instead for discussion, it can be a separate PR. |
If you nuke |
Oh hm that's how the iOS and android ephemeral directories work. I guess the naming did confuse me. |
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.
LGTM, but I'd prefer we remove Pods for macOS.
I filed #39003, a separate PR wouldn't conflict with this change. |
On macOS, the goal is for Flutter/ephemeral to contain everything that's not checked in (Pods is currently a major outlier) generated by Flutter tooling. That includes the xcconfig, which will break building from within Xcode. |
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.
LGTM
@@ -28,38 +32,70 @@ class CleanCommand extends FlutterCommand { | |||
|
|||
@override | |||
Future<FlutterCommandResult> runCommand() async { | |||
// Clean Xcode to remove intermediate DerivedData artifacts. | |||
// Do this before removing ephemeral directory, which would delete the xcworkspace. | |||
final FlutterProject flutterProject = FlutterProject.current(); |
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.
noob question, do we already know they're in a valid flutter project directory?
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.
flutter clean
requires a pubspec.yaml
$ flutter clean
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Do not run this command from the root of your git clone of Flutter.
if (!xcodeProject.existsSync()) { | ||
return; | ||
} | ||
final Status xcodeStatus = logger.startProgress('Cleaning Xcode workspace...', timeout: timeoutConfiguration.slowOperation); |
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.
I think it'll be possible to have both an iOS and a macOS project right? Should this message be more specific?
@stuartmorgan, Jenn's been moving the env var setting in the xcconfigs into an env setting .sh. We should be consistent on the 2 platforms. We should also be consistent about where the outputs of flutter build aar/ios-framework go. If they go to build/, then dependent platform projects will also break if that's where they pointed their dependencies to. So there, it would be consistent with dependent macOS apps not building as well. But I'm not sure if we thought these effects and explicitly decided on them. |
Hi @jmagman
I have no idea what's going on :/ it's not like this with every build (usually it's about 40-60s), but it's very annoying and significantly increasing our CI builds and tests. To give You a better background of why it's important for us:
To prevent possible build issues we created a couple of: UI tests using Flutter Driver, static code analysis, and unit tests - and use them as a part of our continues integration process. Do You have any idea why cleaning xcode workspace is so long sometimes? Is there any way to make this faster? Or at least debug to better understand the reasons and improve? BTW: We are using Azure DevOps for our CI/CD. But we have similar issues with flutter clean on our local Macbooks. Thanks in advance! |
@PiotrWpl I'm not sure why cleaning the workspace would take that long. Unfortunately running:
in Can you file an issue for why you need to run Can you make your own CI script instead of relying on |
flutter/flutter#38992 以下のエラーに対処するため。 ``` error: Could not delete `/Users/runner/runners/2.262.1/work/whimsicalendar/whimsicalendar/build/ios` because it was not created by the build system. ```
flutter/flutter#38992 以下のエラーに対処するため。 ``` error: Could not delete `/Users/runner/runners/2.262.1/work/whimsicalendar/whimsicalendar/build/ios` because it was not created by the build system. ```
flutter/flutter#38992 以下のエラーに対処するため。 ``` error: Could not delete `/Users/runner/runners/2.262.1/work/whimsicalendar/whimsicalendar/build/ios` because it was not created by the build system. ```
flutter/flutter#38992 以下のエラーに対処するため。 ``` error: Could not delete `/Users/runner/runners/2.262.1/work/whimsicalendar/whimsicalendar/build/ios` because it was not created by the build system. ```
flutter/flutter#38992 以下のエラーに対処するため。 ``` error: Could not delete `/Users/runner/runners/2.262.1/work/whimsicalendar/whimsicalendar/build/ios` because it was not created by the build system. ```
Description
Related Issues
Fixes #34462
Tests
I updated clean_test, swapped it to a MemoryFileSystem since the macOS directory structure was getting to be a lot with mocks.
Checklist
///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change