Skip to content

Commit 0009545

Browse files
authored
[ci] Run 'flutter build --config-only for iOS and macOS during fetch deps (flutter#5804)
For iOS and macOS move fetch deps from explicity running `pub get` and `pod install` to instead run `flutter build x --config-only` which smartly fetches deps and lays down the required native pieces. I didn't guard it on whether certain files are present since the command already has similar guards, and runs pretty fast if the native code has already been generated. This fixes an issue where `pod install` is run before the Flutter native bits and migrations are run. Fixes issues seen in the Flutter roll flutter/packages#5792 (comment) ``` Running command: "pod install" in /Volumes/Work/s/w/ir/x/w/packages/packages/camera/camera_avfoundation/example/ios Analyzing dependencies [!] CocoaPods could not find compatible versions for pod "Flutter": In Podfile: Flutter (from `Flutter`) Specs satisfying the `Flutter (from `Flutter`)` dependency were found, but they required a higher minimum deployment target. [!] Automatically assigning platform `iOS` with version `11.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`. Unable to "pod install" ``` Caused by flutter#140478
1 parent 15115f3 commit 0009545

2 files changed

Lines changed: 25 additions & 286 deletions

File tree

script/tool/lib/src/fetch_deps_command.dart

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:file/file.dart';
6-
75
import 'common/core.dart';
86
import 'common/gradle.dart';
97
import 'common/output_utils.dart';
@@ -216,44 +214,15 @@ class FetchDepsCommand extends PackageLoopingCommand {
216214
}
217215

218216
for (final RepositoryPackage example in package.getExamples()) {
219-
final Directory platformDir =
220-
example.platformDirectory(getPlatformByName(platform));
221-
222-
// Running `pod install` requires `flutter pub get` or `flutter build` to
223-
// have been run at some point to create the necessary native build files.
224-
// See https://github.com/flutter/flutter/blob/fb7a763c640d247d090cbb373e4b3a0459ac171b/packages/flutter_tools/templates/cocoapods/Podfile-macos#L13-L15
225-
// and https://github.com/flutter/flutter/blob/fb7a763c640d247d090cbb373e4b3a0459ac171b/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift#L14-L16
226-
final File generatedXCConfig = platform == platformMacOS
227-
? platformDir
228-
.childDirectory('Flutter')
229-
.childDirectory('ephemeral')
230-
.childFile('Flutter-Generated.xcconfig')
231-
: platformDir
232-
.childDirectory('Flutter')
233-
.childFile('Generated.xcconfig');
234-
if (!generatedXCConfig.existsSync()) {
235-
final int exitCode = await processRunner.runAndStream(
236-
flutterCommand,
237-
<String>['pub', 'get'],
238-
workingDir: example.directory,
239-
);
240-
if (exitCode != 0) {
241-
printError('Unable to prepare native project files.');
242-
return PackageResult.fail(<String>['Unable to configure project.']);
243-
}
244-
}
245-
217+
// Create the necessary native build files, which will run pub get and pod install if needed.
246218
final int exitCode = await processRunner.runAndStream(
247-
'pod',
248-
<String>['install'],
249-
workingDir: platformDir,
250-
environment: <String, String>{
251-
'LANG': 'en_US.UTF-8',
252-
},
219+
flutterCommand,
220+
<String>['build', platform, '--config-only'],
221+
workingDir: example.directory,
253222
);
254223
if (exitCode != 0) {
255-
printError('Unable to "pod install"');
256-
return PackageResult.fail(<String>['Unable to "pod install"']);
224+
printError('Unable to prepare native project files.');
225+
return PackageResult.fail(<String>['Unable to configure project.']);
257226
}
258227
}
259228

0 commit comments

Comments
 (0)