Revert "Use FlutterProject to locate files (#18913)" (#19409)
This reverts commit 57d78cc739a1d21a981886d424a6a104c8d48e33.
diff --git a/packages/flutter_tools/test/ios/cocoapods_test.dart b/packages/flutter_tools/test/ios/cocoapods_test.dart
index fe43de4..b65e757 100644
--- a/packages/flutter_tools/test/ios/cocoapods_test.dart
+++ b/packages/flutter_tools/test/ios/cocoapods_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart';
+import 'package:flutter_tools/src/flutter_manifest.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/ios/cocoapods.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
@@ -24,7 +25,7 @@
FileSystem fs;
ProcessManager mockProcessManager;
MockXcodeProjectInterpreter mockXcodeProjectInterpreter;
- FlutterProject projectUnderTest;
+ Directory projectUnderTest;
CocoaPods cocoaPodsUnderTest;
InvokeProcess resultOfPodVersion;
@@ -45,8 +46,7 @@
fs = new MemoryFileSystem();
mockProcessManager = new MockProcessManager();
mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter();
- projectUnderTest = new FlutterProject(fs.directory('project'));
- projectUnderTest.ios.directory.createSync(recursive: true);
+ projectUnderTest = fs.directory(fs.path.join('project', 'ios'))..createSync(recursive: true);
cocoaPodsUnderTest = new CocoaPods();
pretendPodVersionIs('1.5.0');
fs.file(fs.path.join(
@@ -124,10 +124,22 @@
});
group('Setup Podfile', () {
- testUsingContext('creates objective-c Podfile when not present', () async {
- cocoaPodsUnderTest.setupPodfile(projectUnderTest.ios);
+ File podFile;
+ File debugConfigFile;
+ File releaseConfigFile;
- expect(projectUnderTest.ios.podfile.readAsStringSync(), 'Objective-C podfile template');
+ setUp(() {
+ debugConfigFile = fs.file(fs.path.join('project', 'ios', 'Flutter', 'Debug.xcconfig'));
+ releaseConfigFile = fs.file(fs.path.join('project', 'ios', 'Flutter', 'Release.xcconfig'));
+ podFile = fs.file(fs.path.join('project', 'ios', 'Podfile'));
+ });
+
+ testUsingContext('creates objective-c Podfile when not present', () async {
+ final FlutterManifest manifest =
+ await new FlutterProject.fromPath('project').manifest;
+ cocoaPodsUnderTest.setupPodfile('project', manifest);
+
+ expect(podFile.readAsStringSync(), 'Objective-C podfile template');
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -138,22 +150,24 @@
'SWIFT_VERSION': '4.0',
});
- final FlutterProject project = new FlutterProject.fromPath('project');
- cocoaPodsUnderTest.setupPodfile(project.ios);
+ final FlutterManifest manifest =
+ await new FlutterProject.fromPath('project').manifest;
+ cocoaPodsUnderTest.setupPodfile('project', manifest);
- expect(projectUnderTest.ios.podfile.readAsStringSync(), 'Swift podfile template');
+ expect(podFile.readAsStringSync(), 'Swift podfile template');
}, overrides: <Type, Generator>{
FileSystem: () => fs,
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
});
testUsingContext('does not recreate Podfile when already present', () async {
- projectUnderTest.ios.podfile..createSync()..writeAsStringSync('Existing Podfile');
+ podFile..createSync()..writeAsStringSync('Existing Podfile');
- final FlutterProject project = new FlutterProject.fromPath('project');
- cocoaPodsUnderTest.setupPodfile(project.ios);
+ final FlutterManifest manifest =
+ await new FlutterProject.fromPath('project').manifest;
+ cocoaPodsUnderTest.setupPodfile('project', manifest);
- expect(projectUnderTest.ios.podfile.readAsStringSync(), 'Existing Podfile');
+ expect(podFile.readAsStringSync(), 'Existing Podfile');
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -161,32 +175,30 @@
testUsingContext('does not create Podfile when we cannot interpret Xcode projects', () async {
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(false);
- final FlutterProject project = new FlutterProject.fromPath('project');
- cocoaPodsUnderTest.setupPodfile(project.ios);
+ final FlutterManifest manifest =
+ await new FlutterProject.fromPath('project').manifest;
+ cocoaPodsUnderTest.setupPodfile('project', manifest);
- expect(projectUnderTest.ios.podfile.existsSync(), false);
+ expect(podFile.existsSync(), false);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
});
testUsingContext('includes Pod config in xcconfig files, if not present', () async {
- projectUnderTest.ios.podfile..createSync()..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.xcodeConfigFor('Debug')
- ..createSync(recursive: true)
- ..writeAsStringSync('Existing debug config');
- projectUnderTest.ios.xcodeConfigFor('Release')
- ..createSync(recursive: true)
- ..writeAsStringSync('Existing release config');
+ podFile..createSync()..writeAsStringSync('Existing Podfile');
+ debugConfigFile..createSync(recursive: true)..writeAsStringSync('Existing debug config');
+ releaseConfigFile..createSync(recursive: true)..writeAsStringSync('Existing release config');
- final FlutterProject project = new FlutterProject.fromPath('project');
- cocoaPodsUnderTest.setupPodfile(project.ios);
+ final FlutterManifest manifest =
+ await new FlutterProject.fromPath('project').manifest;
+ cocoaPodsUnderTest.setupPodfile('project', manifest);
- final String debugContents = projectUnderTest.ios.xcodeConfigFor('Debug').readAsStringSync();
+ final String debugContents = debugConfigFile.readAsStringSync();
expect(debugContents, contains(
'#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"\n'));
expect(debugContents, contains('Existing debug config'));
- final String releaseContents = projectUnderTest.ios.xcodeConfigFor('Release').readAsStringSync();
+ final String releaseContents = releaseConfigFile.readAsStringSync();
expect(releaseContents, contains(
'#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"\n'));
expect(releaseContents, contains('Existing release config'));
@@ -198,9 +210,9 @@
group('Process pods', () {
testUsingContext('prints error, if CocoaPods is not installed', () async {
pretendPodIsNotInstalled();
- projectUnderTest.ios.podfile.createSync();
+ projectUnderTest.childFile('Podfile').createSync();
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
);
verifyNever(mockProcessManager.run(
@@ -219,7 +231,7 @@
testUsingContext('throws, if Podfile is missing.', () async {
try {
await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
);
fail('ToolExit expected');
@@ -266,7 +278,7 @@
));
try {
await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
);
fail('ToolExit expected');
@@ -283,14 +295,14 @@
});
testUsingContext('run pod install, if Podfile.lock is missing', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Existing lock file.');
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: false,
);
@@ -306,14 +318,14 @@
});
testUsingContext('runs pod install, if Manifest.lock is missing', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: false,
);
@@ -332,17 +344,17 @@
});
testUsingContext('runs pod install, if Manifest.lock different from Podspec.lock', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Different lock file.');
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: false,
);
@@ -361,17 +373,17 @@
});
testUsingContext('runs pod install, if flutter framework changed', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Existing lock file.');
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: true,
);
@@ -390,20 +402,20 @@
});
testUsingContext('runs pod install, if Podfile.lock is older than Podfile', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Existing lock file.');
await new Future<void>.delayed(const Duration(milliseconds: 10));
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..writeAsStringSync('Updated Podfile');
await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: false,
);
@@ -421,17 +433,17 @@
});
testUsingContext('skips pod install, if nothing changed', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Existing lock file.');
final bool didInstall = await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: false,
);
@@ -447,13 +459,13 @@
});
testUsingContext('a failed pod install deletes Pods/Manifest.lock', () async {
- projectUnderTest.ios.podfile
+ projectUnderTest.childFile('Podfile')
..createSync()
..writeAsStringSync('Existing Podfile');
- projectUnderTest.ios.podfileLock
+ projectUnderTest.childFile('Podfile.lock')
..createSync()
..writeAsStringSync('Existing lock file.');
- projectUnderTest.ios.podManifestLock
+ projectUnderTest.childFile('Pods/Manifest.lock')
..createSync(recursive: true)
..writeAsStringSync('Existing lock file.');
@@ -470,13 +482,13 @@
try {
await cocoaPodsUnderTest.processPods(
- iosProject: projectUnderTest.ios,
+ appIosDirectory: projectUnderTest,
iosEngineDir: 'engine/path',
dependenciesChanged: true,
);
fail('Tool throw expected when pod install fails');
} on ToolExit {
- expect(projectUnderTest.ios.podManifestLock.existsSync(), isFalse);
+ expect(projectUnderTest.childFile('Pods/Manifest.lock').existsSync(), isFalse);
}
}, overrides: <Type, Generator>{
FileSystem: () => fs,