From ef792fc30db2d062674c2a8a635cb8305c6433c4 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 3 Jun 2019 16:11:33 -0700 Subject: [PATCH] Disable CocoaPods input and output paths in Xcode build phase and adopt new Xcode build system (#33684) Updates the Podfile template to use the CocoaPod disable_input_output_paths installation option which prevents the [CP] Embed Pods Frameworks build phase from outputting the Flutter.framework files. --- .cirrus.yml | 2 + .../android_views/ios/Podfile | 3 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- dev/integration_tests/ios_add2app/Podfile | 3 + .../ios_add2app.xcodeproj/project.pbxproj | 3 - .../Host.xcodeproj/project.pbxproj | 3 - dev/integration_tests/ios_host_app/Podfile | 3 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- examples/flutter_gallery/ios/Podfile | 3 + .../ios/Runner.xcodeproj/project.pbxproj | 3 - .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- examples/flutter_view/ios/Podfile | 3 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- examples/platform_view/ios/Podfile | 3 + .../ios/Runner.xcodeproj/project.pbxproj | 3 - .../xcshareddata/WorkspaceSettings.xcsettings | 8 -- .../flutter_tools/lib/src/context_runner.dart | 1 - packages/flutter_tools/lib/src/ios/mac.dart | 96 ------------------- .../lib/src/macos/cocoapods.dart | 4 +- .../templates/cocoapods/Podfile-ios-objc | 3 + .../templates/cocoapods/Podfile-ios-swift | 3 + .../templates/cocoapods/Podfile-macos | 3 + .../test/commands/create_test.dart | 7 +- packages/flutter_tools/test/ios/mac_test.dart | 68 ------------- .../test/macos/cocoapods_test.dart | 15 +-- 27 files changed, 40 insertions(+), 248 deletions(-) delete mode 100644 dev/integration_tests/codegen/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 dev/integration_tests/flavors/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 examples/catalog/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 examples/flutter_gallery/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 examples/hello_world/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 examples/platform_channel/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 examples/stocks/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/.cirrus.yml b/.cirrus.yml index 3542241e09..5bfa12b64d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -178,6 +178,8 @@ task: # with the actual time - this should help to verify print_date_script: - date + install_cocoapods_script: + - sudo gem install cocoapods git_fetch_script: - git clean -xfd - git fetch origin diff --git a/dev/integration_tests/android_views/ios/Podfile b/dev/integration_tests/android_views/ios/Podfile index f1f71941d4..64ba7492ea 100644 --- a/dev/integration_tests/android_views/ios/Podfile +++ b/dev/integration_tests/android_views/ios/Podfile @@ -60,6 +60,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/dev/integration_tests/codegen/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/dev/integration_tests/codegen/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/dev/integration_tests/codegen/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/dev/integration_tests/flavors/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/dev/integration_tests/flavors/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/dev/integration_tests/flavors/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/dev/integration_tests/ios_add2app/Podfile b/dev/integration_tests/ios_add2app/Podfile index 3904962da2..72e1973f10 100644 --- a/dev/integration_tests/ios_add2app/Podfile +++ b/dev/integration_tests/ios_add2app/Podfile @@ -1,5 +1,8 @@ platform :ios, '12.0' +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + flutter_application_path = 'flutterapp/' framework_dir = File.join(flutter_application_path, '.ios', 'Flutter') diff --git a/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj b/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj index 8ac6d94d7d..1859736254 100644 --- a/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_add2app/ios_add2app.xcodeproj/project.pbxproj @@ -328,14 +328,11 @@ inputFileListPaths = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-ios_add2app/Pods-ios_add2app-frameworks.sh", - "${PODS_ROOT}/../flutterapp/.ios/Flutter/engine/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( ); outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj b/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj index 5fbcfe441b..b7edca54cc 100644 --- a/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj +++ b/dev/integration_tests/ios_host_app/Host.xcodeproj/project.pbxproj @@ -206,12 +206,9 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Host/Pods-Host-frameworks.sh", - "${PODS_ROOT}/../../hello/.ios/Flutter/engine/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/dev/integration_tests/ios_host_app/Podfile b/dev/integration_tests/ios_host_app/Podfile index ec1b8b9120..2b94908a24 100644 --- a/dev/integration_tests/ios_host_app/Podfile +++ b/dev/integration_tests/ios_host_app/Podfile @@ -1,5 +1,8 @@ platform :ios, '9.0' +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + target 'Host' do flutter_application_path = '../hello' eval(File.read("#{flutter_application_path}/.ios/Flutter/podhelper.rb")) diff --git a/examples/catalog/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/catalog/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/examples/catalog/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/examples/flutter_gallery/ios/Podfile b/examples/flutter_gallery/ios/Podfile index 49fd574d25..e8ba04f2f4 100644 --- a/examples/flutter_gallery/ios/Podfile +++ b/examples/flutter_gallery/ios/Podfile @@ -37,6 +37,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj b/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj index 739e234d1c..c8c1492bf3 100644 --- a/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/flutter_gallery/ios/Runner.xcodeproj/project.pbxproj @@ -267,12 +267,9 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../../../../bin/cache/artifacts/engine/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/examples/flutter_gallery/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/flutter_gallery/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/examples/flutter_gallery/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/examples/flutter_view/ios/Podfile b/examples/flutter_view/ios/Podfile index 3b095c3a6e..f29633fb28 100644 --- a/examples/flutter_view/ios/Podfile +++ b/examples/flutter_view/ios/Podfile @@ -1,6 +1,9 @@ # Uncomment this line to define a global platform for your project # platform :ios, '9.0' +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + target 'Runner' do # Uncomment this line if you're using Swift or would like to use dynamic frameworks use_frameworks! diff --git a/examples/hello_world/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/hello_world/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/examples/hello_world/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/examples/platform_channel/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/platform_channel/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/examples/platform_channel/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/examples/platform_view/ios/Podfile b/examples/platform_view/ios/Podfile index dcc6b981d4..0938dafd63 100644 --- a/examples/platform_view/ios/Podfile +++ b/examples/platform_view/ios/Podfile @@ -56,6 +56,9 @@ target 'Runner' do pod 'MaterialControls' end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj b/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj index d9d41b76d0..6aadd67de1 100644 --- a/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj +++ b/examples/platform_view/ios/Runner.xcodeproj/project.pbxproj @@ -230,12 +230,9 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/examples/stocks/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/stocks/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678982..0000000000 --- a/examples/stocks/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - - diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index 182130a5dc..40a0d51ea1 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -92,7 +92,6 @@ Future runInContext( Logger: () => platform.isWindows ? WindowsStdoutLogger() : StdoutLogger(), MacOSWorkflow: () => const MacOSWorkflow(), OperatingSystemUtils: () => OperatingSystemUtils(), - PlistBuddy: () => const PlistBuddy(), SimControl: () => SimControl(), Stdio: () => const Stdio(), SystemClock: () => const SystemClock(), diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 59a0153b9c..e29da673b9 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -28,55 +28,6 @@ import 'code_signing.dart'; import 'xcodeproj.dart'; IMobileDevice get iMobileDevice => context.get(); -PlistBuddy get plistBuddy => context.get(); - -class PlistBuddy { - const PlistBuddy(); - - static const String path = '/usr/libexec/PlistBuddy'; - - Future run(List args) => processManager.run([path]..addAll(args)); -} - -/// A property list is a key-value representation commonly used for -/// configuration on macOS/iOS systems. -class PropertyList { - const PropertyList(this.plistPath); - - final String plistPath; - - /// Prints the specified key, or returns null if not present. - Future read(String key) async { - final ProcessResult result = await _runCommand('Print $key'); - if (result.exitCode == 0) - return result.stdout.trim(); - return null; - } - - /// Adds [key]. Has no effect if the key already exists. - Future addString(String key, String value) async { - await _runCommand('Add $key string $value'); - } - - /// Updates [key] with the new [value]. Has no effect if the key does not exist. - Future update(String key, String value) async { - await _runCommand('Set $key $value'); - } - - /// Deletes [key]. - Future delete(String key) async { - await _runCommand('Delete $key'); - } - - /// Deletes the content of the property list and creates a new root of the specified type. - Future clearToDict() async { - await _runCommand('Clear dict'); - } - - Future _runCommand(String command) async { - return await plistBuddy.run(['-c', command, plistPath]); - } -} /// Specialized exception for expected situations where the ideviceinfo /// tool responds with exit code 255 / 'No device found' message @@ -149,47 +100,6 @@ class IMobileDevice { } } -/// Sets the Xcode system. -/// -/// Xcode 10 added a new (default) build system with better performance and -/// stricter checks. Flutter apps without plugins build fine under the new -/// system, but it causes build breakages in projects with CocoaPods enabled. -/// This affects Flutter apps with plugins. -/// -/// Once Flutter has been updated to be fully compliant with the new build -/// system, this can be removed. -// -// TODO(cbracken): remove when https://github.com/flutter/flutter/issues/20685 is fixed. -Future setXcodeWorkspaceBuildSystem({ - @required Directory workspaceDirectory, - @required File workspaceSettings, - @required bool modern, -}) async { - // If this isn't a workspace, we're not using CocoaPods and can use the new - // build system. - if (!workspaceDirectory.existsSync()) - return; - - final PropertyList plist = PropertyList(workspaceSettings.path); - if (!workspaceSettings.existsSync()) { - workspaceSettings.parent.createSync(recursive: true); - await plist.clearToDict(); - } - - const String kBuildSystemType = 'BuildSystemType'; - if (modern) { - printTrace('Using new Xcode build system.'); - await plist.delete(kBuildSystemType); - } else { - printTrace('Using legacy Xcode build system.'); - if (await plist.read(kBuildSystemType) == null) { - await plist.addString(kBuildSystemType, 'Original'); - } else { - await plist.update(kBuildSystemType, 'Original'); - } - } -} - Future buildXcodeProject({ BuildableIOSApp app, BuildInfo buildInfo, @@ -205,12 +115,6 @@ Future buildXcodeProject({ if (!_checkXcodeVersion()) return XcodeBuildResult(success: false); - // TODO(cbracken): remove when https://github.com/flutter/flutter/issues/20685 is fixed. - await setXcodeWorkspaceBuildSystem( - workspaceDirectory: app.project.xcodeWorkspace, - workspaceSettings: app.project.xcodeWorkspaceSharedSettings, - modern: false, - ); final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(app.project.hostAppRoot.path); if (!projectInfo.targets.contains('Runner')) { diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart index 868b0e98c4..9462395b72 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapods.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart @@ -57,8 +57,8 @@ enum CocoaPodsStatus { class CocoaPods { Future _versionText; - String get cocoaPodsMinimumVersion => '1.0.0'; - String get cocoaPodsRecommendedVersion => '1.5.0'; + String get cocoaPodsMinimumVersion => '1.6.0'; + String get cocoaPodsRecommendedVersion => '1.6.0'; Future get cocoaPodsVersionText { _versionText ??= runAsync(['pod', '--version']).then((RunResult result) { diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc b/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc index f1f71941d4..64ba7492ea 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc +++ b/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc @@ -60,6 +60,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift b/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift index 3f49388a9a..e9286cbac1 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift +++ b/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift @@ -62,6 +62,9 @@ target 'Runner' do } end +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| diff --git a/packages/flutter_tools/templates/cocoapods/Podfile-macos b/packages/flutter_tools/templates/cocoapods/Podfile-macos index ec3967f31c..0ef5e94f53 100644 --- a/packages/flutter_tools/templates/cocoapods/Podfile-macos +++ b/packages/flutter_tools/templates/cocoapods/Podfile-macos @@ -77,3 +77,6 @@ target 'Runner' do end } end + +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true diff --git a/packages/flutter_tools/test/commands/create_test.dart b/packages/flutter_tools/test/commands/create_test.dart index 3b5eee55f6..9ef03072f8 100644 --- a/packages/flutter_tools/test/commands/create_test.dart +++ b/packages/flutter_tools/test/commands/create_test.dart @@ -473,8 +473,8 @@ void main() { await runner.run(['create', '--template=module', '--no-pub', '--org', 'com.foo.bar', projectDir.path]); - void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + void expectExists(String relPath, [bool expectation = true]) { + expect(fs.isFileSync('${projectDir.path}/$relPath'), expectation); } expectExists('lib/main.dart'); @@ -515,6 +515,9 @@ void main() { final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath)); final String xcodeProject = xcodeProjectFile.readAsStringSync(); expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject')); + // Xcode build system + final String xcodeWorkspaceSettingsPath = fs.path.join('.ios', 'Runner.xcworkspace', 'xcshareddata', 'WorkspaceSettings.xcsettings'); + expectExists(xcodeWorkspaceSettingsPath, false); final String versionPath = fs.path.join('.metadata'); expectExists(versionPath); diff --git a/packages/flutter_tools/test/ios/mac_test.dart b/packages/flutter_tools/test/ios/mac_test.dart index ba50d7ef4e..8124ed8e21 100644 --- a/packages/flutter_tools/test/ios/mac_test.dart +++ b/packages/flutter_tools/test/ios/mac_test.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:file/file.dart'; -import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult; import 'package:flutter_tools/src/ios/mac.dart'; @@ -29,73 +28,6 @@ class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterprete class MockIosProject extends Mock implements IosProject {} void main() { - group('PropertyList', () { - MockProcessManager mockProcessManager; - MemoryFileSystem fs; - Directory workspaceDirectory; - File workspaceSettingsFile; - - setUp(() { - mockProcessManager = MockProcessManager(); - fs = MemoryFileSystem(); - workspaceDirectory = fs.directory('Runner.xcworkspace'); - workspaceSettingsFile = workspaceDirectory.childDirectory('xcshareddata').childFile('WorkspaceSettings.xcsettings'); - }); - - testUsingContext('does nothing if workspace directory does not exist', () async { - await setXcodeWorkspaceBuildSystem(workspaceDirectory: workspaceDirectory, workspaceSettings: workspaceSettingsFile, modern: false); - verifyNever(mockProcessManager.run([PlistBuddy.path, '-c', 'Print BuildSystemType', workspaceSettingsFile.path])); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => mockProcessManager, - }); - - testUsingContext('creates dict-based plist if settings file does not exist', () async { - workspaceSettingsFile.parent.createSync(recursive: true); - when(mockProcessManager.run([PlistBuddy.path, '-c', 'Print BuildSystemType', workspaceSettingsFile.path])) - .thenAnswer((_) => Future.value(ProcessResult(1, 1, '', ''))); - await setXcodeWorkspaceBuildSystem(workspaceDirectory: workspaceDirectory, workspaceSettings: workspaceSettingsFile, modern: false); - verify(mockProcessManager.run([PlistBuddy.path, '-c', 'Clear dict', workspaceSettingsFile.path])); - verify(mockProcessManager.run([PlistBuddy.path, '-c', 'Add BuildSystemType string Original', workspaceSettingsFile.path])); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => mockProcessManager, - }); - - testUsingContext('writes legacy build mode settings if requested and not present', () async { - workspaceSettingsFile.createSync(recursive: true); - when(mockProcessManager.run([PlistBuddy.path, '-c', 'Print BuildSystemType', workspaceSettingsFile.path])) - .thenAnswer((_) => Future.value(ProcessResult(1, 1, '', ''))); - await setXcodeWorkspaceBuildSystem(workspaceDirectory: workspaceDirectory, workspaceSettings: workspaceSettingsFile, modern: false); - verify(mockProcessManager.run([PlistBuddy.path, '-c', 'Add BuildSystemType string Original', workspaceSettingsFile.path])); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => mockProcessManager, - }); - - testUsingContext('updates legacy build mode setting if requested and existing setting is present', () async { - workspaceSettingsFile.createSync(recursive: true); - when(mockProcessManager.run([PlistBuddy.path, '-c', 'Print BuildSystemType', workspaceSettingsFile.path])) - .thenAnswer((_) => Future.value(ProcessResult(1, 0, 'FancyNewOne', ''))); - await setXcodeWorkspaceBuildSystem(workspaceDirectory: workspaceDirectory, workspaceSettings: workspaceSettingsFile, modern: false); - verify(mockProcessManager.run([PlistBuddy.path, '-c', 'Set BuildSystemType Original', workspaceSettingsFile.path])); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => mockProcessManager, - }); - - testUsingContext('deletes legacy build mode setting if modern build mode requested', () async { - workspaceSettingsFile.createSync(recursive: true); - when(mockProcessManager.run([PlistBuddy.path, '-c', 'Print BuildSystemType', workspaceSettingsFile.path])) - .thenAnswer((_) => Future.value(ProcessResult(1, 0, 'Original', ''))); - await setXcodeWorkspaceBuildSystem(workspaceDirectory: workspaceDirectory, workspaceSettings: workspaceSettingsFile, modern: true); - verify(mockProcessManager.run([PlistBuddy.path, '-c', 'Delete BuildSystemType', workspaceSettingsFile.path])); - }, overrides: { - FileSystem: () => fs, - ProcessManager: () => mockProcessManager, - }); - }); - group('IMobileDevice', () { final FakePlatform osx = FakePlatform.fromPlatform(const LocalPlatform()) ..operatingSystem = 'macos'; diff --git a/packages/flutter_tools/test/macos/cocoapods_test.dart b/packages/flutter_tools/test/macos/cocoapods_test.dart index 82b8aa9a9e..bc2afa6f43 100644 --- a/packages/flutter_tools/test/macos/cocoapods_test.dart +++ b/packages/flutter_tools/test/macos/cocoapods_test.dart @@ -60,7 +60,7 @@ void main() { projectUnderTest = FlutterProject.fromDirectory(fs.directory('project')); projectUnderTest.ios.xcodeProject.createSync(recursive: true); cocoaPodsUnderTest = CocoaPods(); - pretendPodVersionIs('1.5.0'); + pretendPodVersionIs('1.6.0'); fs.file(fs.path.join( Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc', )) @@ -123,28 +123,21 @@ void main() { }); testUsingContext('detects below minimum version', () async { - pretendPodVersionIs('0.39.8'); + pretendPodVersionIs('1.5.0'); expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowMinimumVersion); }, overrides: { ProcessManager: () => mockProcessManager, }); - testUsingContext('detects below recommended version', () async { - pretendPodVersionIs('1.4.99'); - expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowRecommendedVersion); - }, overrides: { - ProcessManager: () => mockProcessManager, - }); - testUsingContext('detects at recommended version', () async { - pretendPodVersionIs('1.5.0'); + pretendPodVersionIs('1.6.0'); expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended); }, overrides: { ProcessManager: () => mockProcessManager, }); testUsingContext('detects above recommended version', () async { - pretendPodVersionIs('1.5.1'); + pretendPodVersionIs('1.6.1'); expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended); }, overrides: { ProcessManager: () => mockProcessManager,