Commit 1d20a90c authored by Devon Carew's avatar Devon Carew

change how we calculate the temp dir

parent 30c4c4f7
...@@ -239,7 +239,7 @@ Future<_ApkComponents> _findApkComponents( ...@@ -239,7 +239,7 @@ Future<_ApkComponents> _findApkComponents(
await parseServiceConfigs(components.services, jars: components.jars); await parseServiceConfigs(components.services, jars: components.jars);
for (File file in [ for (File file in <File>[
components.manifest, components.icuData, components.libSkyShell, components.debugKeystore components.manifest, components.icuData, components.libSkyShell, components.debugKeystore
]..addAll(components.jars)) { ]..addAll(components.jars)) {
if (!file.existsSync()) { if (!file.existsSync()) {
......
...@@ -13,7 +13,7 @@ import '../base/process.dart'; ...@@ -13,7 +13,7 @@ import '../base/process.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command_runner.dart'; import '../runner/flutter_command_runner.dart';
Future<bool> _inflateXcodeArchive(String directory, List<int> archiveBytes) async { bool _inflateXcodeArchive(String directory, List<int> archiveBytes) {
printStatus('Unzipping Xcode project to local directory...'); printStatus('Unzipping Xcode project to local directory...');
// We cannot use ArchiveFile because this archive contains files that are exectuable // We cannot use ArchiveFile because this archive contains files that are exectuable
...@@ -21,28 +21,33 @@ Future<bool> _inflateXcodeArchive(String directory, List<int> archiveBytes) asyn ...@@ -21,28 +21,33 @@ Future<bool> _inflateXcodeArchive(String directory, List<int> archiveBytes) asyn
// or after creation. See https://github.com/dart-lang/sdk/issues/15078. // or after creation. See https://github.com/dart-lang/sdk/issues/15078.
// So we depend on the platform to unzip the archive for us. // So we depend on the platform to unzip the archive for us.
Directory tempDir = await Directory.systemTemp.create(); Directory tempDir = Directory.systemTemp.createTempSync('flutter_xcode');
File tempFile = new File(path.join(tempDir.path, 'FlutterXcode.zip'))..createSync(); File tempFile = new File(path.join(tempDir.path, 'FlutterXcode.zip'))..createSync();
tempFile.writeAsBytesSync(archiveBytes); tempFile.writeAsBytesSync(archiveBytes);
try { try {
Directory dir = new Directory(directory);
// Remove the old generated project if one is present // Remove the old generated project if one is present
runCheckedSync(['/bin/rm', '-rf', directory]); if (dir.existsSync())
dir.deleteSync(recursive: true);
// Create the directory so unzip can write to it // Create the directory so unzip can write to it
runCheckedSync(['/bin/mkdir', '-p', directory]); dir.createSync(recursive: true);
// Unzip the Xcode project into the new empty directory // Unzip the Xcode project into the new empty directory
runCheckedSync(['/usr/bin/unzip', tempFile.path, '-d', directory]); runCheckedSync(['/usr/bin/unzip', tempFile.path, '-d', dir.path]);
} catch (error) { } catch (error) {
printTrace('$error');
return false; return false;
} }
// Cleanup the temp directory after unzipping // Cleanup the temp directory after unzipping
runSync(['/bin/rm', '-rf', tempDir.path]); tempDir.deleteSync(recursive: true);
// Verify that we have an Xcode project // Verify that we have an Xcode project
Directory flutterProj = new Directory(path.join(directory, 'FlutterApplication.xcodeproj')); Directory flutterProj = new Directory(path.join(directory, 'FlutterApplication.xcodeproj'));
bool flutterProjExists = await flutterProj.exists(); if (!flutterProj.existsSync()) {
if (!flutterProjExists) {
printError("${flutterProj.path} does not exist"); printError("${flutterProj.path} does not exist");
return false; return false;
} }
...@@ -108,7 +113,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async { ...@@ -108,7 +113,7 @@ Future<int> setupXcodeProjectHarness(String flutterProjectPath) async {
} }
// Step 2: Inflate the archive into the user project directory // Step 2: Inflate the archive into the user project directory
bool result = await _inflateXcodeArchive(xcodeprojPath, archiveBytes); bool result = _inflateXcodeArchive(xcodeprojPath, archiveBytes);
if (!result) { if (!result) {
printError('Could not inflate the Xcode project archive.'); printError('Could not inflate the Xcode project archive.');
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment