From 15f271ef07d37b63abc92d245149c09dda99747f Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 23 Apr 2019 09:49:49 -0700 Subject: [PATCH] if there is no .ios or ios sub-project, don't attempt building for iOS (#31406) --- packages/flutter_tools/lib/src/application_package.dart | 7 ++++++- packages/flutter_tools/lib/src/project.dart | 3 +++ packages/flutter_tools/test/application_package_test.dart | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index bf0fe9e271..fa9dfe61e0 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -306,8 +306,13 @@ abstract class IOSApp extends ApplicationPackage { } factory IOSApp.fromIosProject(IosProject project) { - if (getCurrentHostPlatform() != HostPlatform.darwin_x64) + if (getCurrentHostPlatform() != HostPlatform.darwin_x64) { return null; + } + // TODO(jonahwilliams): do more verification in this check. + if (!project.exists) { + return null; + } return BuildableIOSApp(project); } diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index c009017a10..307eaf12c3 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -231,6 +231,9 @@ class IosProject { /// True, if the parent Flutter project is a module project. bool get isModule => parent.isModule; + /// Whether the flutter application has an iOS project. + bool get exists => hostAppRoot.existsSync(); + /// The xcode config file for [mode]. File xcodeConfigFor(String mode) => _flutterLibRoot.childDirectory('Flutter').childFile('$mode.xcconfig'); diff --git a/packages/flutter_tools/test/application_package_test.dart b/packages/flutter_tools/test/application_package_test.dart index 06450edd04..20f3d292ce 100644 --- a/packages/flutter_tools/test/application_package_test.dart +++ b/packages/flutter_tools/test/application_package_test.dart @@ -277,6 +277,14 @@ void main() { expect(iosApp.id, 'fooBundleId'); expect(iosApp.bundleName, 'bundle.app'); }, overrides: overrides); + + testUsingContext('returns null when there is no ios or .ios directory', () async { + fs.file('pubspec.yaml').createSync(); + fs.file('.packages').createSync(); + final BuildableIOSApp iosApp = IOSApp.fromIosProject((await FlutterProject.fromDirectory(fs.currentDirectory)).ios); + + expect(iosApp, null); + }, overrides: overrides); }); }