diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index f3fd2b7f6c92..20eef521de22 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -465,7 +465,9 @@ this command. _printRunningExampleTestsMessage(example, platform); final int exitCode = await _xcode.runXcodeBuild( example.directory, - actions: ['test'], + // Clean before testing to remove cached swiftmodules from previous + // runs, which can cause conflicts. + actions: ['clean', 'test'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner', configuration: 'Debug', diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index e753ccb21fc0..6760eeeff8ef 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -111,7 +111,9 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { print('Running $platform tests and analyzer for $examplePath...'); final int exitCode = await _xcode.runXcodeBuild( example.directory, - actions: ['analyze'], + // Clean before analyzing to remove cached swiftmodules from previous + // runs, which can cause conflicts. + actions: ['clean', 'analyze'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner', configuration: 'Debug', diff --git a/script/tool/test/native_test_command_test.dart b/script/tool/test/native_test_command_test.dart index 993ee86d600c..cd3569739e22 100644 --- a/script/tool/test/native_test_command_test.dart +++ b/script/tool/test/native_test_command_test.dart @@ -139,6 +139,7 @@ void main() { 'xcrun', [ 'xcodebuild', + 'clean', 'test', '-workspace', '$platform/Runner.xcworkspace', @@ -220,7 +221,7 @@ void main() { getMockXcodebuildListProcess(['RunnerTests', 'RunnerUITests']), // Exit code 66 from testing indicates no tests. FakeProcessInfo( - MockProcess(exitCode: 66), ['xcodebuild', 'test']), + MockProcess(exitCode: 66), ['xcodebuild', 'clean', 'test']), ]; final List output = await runCapturingPrint( runner, ['native-test', '--macos', '--no-unit']); @@ -1469,11 +1470,11 @@ public class FlutterActivityTest { getMockXcodebuildListProcess( ['RunnerTests', 'RunnerUITests']), // iOS list FakeProcessInfo( - MockProcess(), ['xcodebuild', 'test']), // iOS run + MockProcess(), ['xcodebuild', 'clean', 'test']), // iOS run getMockXcodebuildListProcess( ['RunnerTests', 'RunnerUITests']), // macOS list FakeProcessInfo( - MockProcess(), ['xcodebuild', 'test']), // macOS run + MockProcess(), ['xcodebuild', 'clean', 'test']), // macOS run ]; final List output = await runCapturingPrint(runner, [ diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index 2caf906fc6a5..cd4fb7306c47 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -106,6 +106,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -146,6 +147,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -244,6 +246,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -278,6 +281,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -350,6 +354,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -366,6 +371,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -406,6 +412,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -445,6 +452,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace',