From 3463d89cf6a932a54bfeb8fc05b493961b9c713d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 22 Feb 2016 12:37:08 -0800 Subject: [PATCH] remove iosSimulator field from ApplicationPackageStore --- .../lib/src/application_package.dart | 25 ++++++------------- .../lib/src/commands/devices.dart | 6 ++--- .../flutter_tools/lib/src/commands/run.dart | 1 + packages/flutter_tools/lib/src/ios/mac.dart | 3 +-- .../lib/src/ios/plist_utils.dart | 10 +++++--- packages/flutter_tools/test/src/mocks.dart | 9 ++++--- 6 files changed, 24 insertions(+), 30 deletions(-) diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index 1a1c30f33a..a36d2873f8 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -88,36 +88,32 @@ class IOSApp extends ApplicationPackage { }) : super(localPath: iosProjectDir, id: iosProjectBundleId); factory IOSApp.fromBuildConfiguration(BuildConfiguration config) { - if (getCurrentHostPlatform() != HostPlatform.mac) { + if (getCurrentHostPlatform() != HostPlatform.mac) return null; - } String plistPath = path.join("ios", "Info.plist"); - String id = plistValueForKey(plistPath, kCFBundleIdentifierKey); - if (id == "") { + String value = getValueFromFile(plistPath, kCFBundleIdentifierKey); + if (value == null) return null; - } String projectDir = path.join("ios", ".generated"); - return new IOSApp(iosProjectDir: projectDir, iosProjectBundleId: id); + return new IOSApp(iosProjectDir: projectDir, iosProjectBundleId: value); } } class ApplicationPackageStore { final AndroidApk android; final IOSApp iOS; - final IOSApp iOSSimulator; - ApplicationPackageStore({ this.android, this.iOS, this.iOSSimulator }); + ApplicationPackageStore({ this.android, this.iOS }); ApplicationPackage getPackageForPlatform(TargetPlatform platform) { switch (platform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: - return iOS; case TargetPlatform.iOSSimulator: - return iOSSimulator; + return iOS; case TargetPlatform.mac: case TargetPlatform.linux: return null; @@ -127,7 +123,6 @@ class ApplicationPackageStore { static Future forConfigs(List configs) async { AndroidApk android; IOSApp iOS; - IOSApp iOSSimulator; for (BuildConfiguration config in configs) { switch (config.targetPlatform) { @@ -150,21 +145,17 @@ class ApplicationPackageStore { break; case TargetPlatform.iOS: + case TargetPlatform.iOSSimulator: assert(iOS == null); iOS = new IOSApp.fromBuildConfiguration(config); break; - case TargetPlatform.iOSSimulator: - assert(iOSSimulator == null); - iOSSimulator = new IOSApp.fromBuildConfiguration(config); - break; - case TargetPlatform.mac: case TargetPlatform.linux: break; } } - return new ApplicationPackageStore(android: android, iOS: iOS, iOSSimulator: iOSSimulator); + return new ApplicationPackageStore(android: android, iOS: iOS); } } diff --git a/packages/flutter_tools/lib/src/commands/devices.dart b/packages/flutter_tools/lib/src/commands/devices.dart index 3a6ebd6735..a6611e400a 100644 --- a/packages/flutter_tools/lib/src/commands/devices.dart +++ b/packages/flutter_tools/lib/src/commands/devices.dart @@ -27,11 +27,11 @@ class DevicesCommand extends FlutterCommand { if (devices.isEmpty) { printStatus('No connected devices.'); } else { - printStatus('${devices.length} connected ${pluralize('device', devices.length)}:'); + printStatus('${devices.length} connected ${pluralize('device', devices.length)}:\n'); for (Device device in devices) { - String supportIndicator = device.isSupported() ? '' : '- unsupported'; - printStatus('${device.name} (${device.id}) $supportIndicator'); + String supportIndicator = device.isSupported() ? '' : ' - unsupported'; + printStatus('${device.name} (${device.id})$supportIndicator'); } } diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index e73f03df51..4ad71be07c 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -170,6 +170,7 @@ Future startApp( if (install) { printTrace('Running install command.'); + // TODO(devoncarew): This fails for ios devices - we haven't built yet. await installApp(devices, applicationPackages); } diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index d31160b11c..163f6f4825 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -59,9 +59,8 @@ class XCode { bool _xcodeVersionSatisfactory; bool get xcodeVersionSatisfactory { - if (_xcodeVersionSatisfactory != null) { + if (_xcodeVersionSatisfactory != null) return _xcodeVersionSatisfactory; - } try { String output = runSync(['xcodebuild', '-version']); diff --git a/packages/flutter_tools/lib/src/ios/plist_utils.dart b/packages/flutter_tools/lib/src/ios/plist_utils.dart index cb9f6a2d98..3916a291de 100644 --- a/packages/flutter_tools/lib/src/ios/plist_utils.dart +++ b/packages/flutter_tools/lib/src/ios/plist_utils.dart @@ -8,7 +8,7 @@ import '../base/process.dart'; const String kCFBundleIdentifierKey = "CFBundleIdentifier"; -String plistValueForKey(String plistFilePath, String plistKey) { +String getValueFromFile(String plistFilePath, String key) { // TODO(chinmaygarde): For now, we only need to read from plist files on a // mac host. If this changes, we will need our own Dart plist reader. @@ -18,12 +18,14 @@ String plistValueForKey(String plistFilePath, String plistKey) { String normalizedPlistPath = path.withoutExtension(path.absolute(plistFilePath)); try { - return runCheckedSync([ + String value = runCheckedSync([ '/usr/bin/defaults', 'read', normalizedPlistPath, - plistKey]).trim(); + key + ]).trim(); + return value.isEmpty ? null : value; } catch (error) { - return ""; + return null; } } diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart index 8936cf9c78..14d8b96f80 100644 --- a/packages/flutter_tools/test/src/mocks.dart +++ b/packages/flutter_tools/test/src/mocks.dart @@ -15,10 +15,11 @@ import 'package:mockito/mockito.dart'; class MockApplicationPackageStore extends ApplicationPackageStore { MockApplicationPackageStore() : super( android: new AndroidApk(localPath: '/mock/path/to/android/SkyShell.apk'), - iOS: new IOSApp(iosProjectDir: '/mock/path/to/iOS/SkyShell.app', - iosProjectBundleId: 'io.flutter.ios.mock'), - iOSSimulator: new IOSApp(iosProjectDir: '/mock/path/to/iOSSimulator/SkyShell.app', - iosProjectBundleId: 'io.flutter.ios.mock')); + iOS: new IOSApp( + iosProjectDir: '/mock/path/to/iOS/SkyShell.app', + iosProjectBundleId: 'io.flutter.ios.mock' + ) + ); } class MockCompiler extends Mock implements Compiler {