Skip to content

Instantly share code, notes, and snippets.

@jmagman
Created March 9, 2022 00:52
Show Gist options
  • Save jmagman/d7b76fc20ff5d5808f6ce26ea3d622e9 to your computer and use it in GitHub Desktop.
Save jmagman/d7b76fc20ff5d5808f6ce26ea3d622e9 to your computer and use it in GitHub Desktop.
CADisableMinimumFrameDurationOnPhone Info.plist migration for https://github.com/flutter/flutter/pull/94509
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '../../base/file_system.dart';
import '../../base/logger.dart';
import '../../base/project_migrator.dart';
import '../../xcode_project.dart';
// Add CADisableMinimumFrameDurationOnPhone to the Info.plist.
class MinimumFrameDurationMigration extends ProjectMigrator {
MinimumFrameDurationMigration(
IosProject project,
Logger logger,
) : _infoPlist = project.defaultHostInfoPlist,
super(logger);
final File _infoPlist;
@override
bool migrate() {
if (!_infoPlist.existsSync()) {
logger.printTrace('Xcode project workspace data not found, skipping minimum frame duration migration.');
return true;
}
processFileLines(_infoPlist);
return true;
}
@override
String migrateFileContents(String fileContents) {
//
if (fileContents.contains('CADisableMinimumFrameDurationOnPhone')) {
return fileContents;
}
const String plistEnd = '''
</dict>
</plist>
''';
const String plistWithKey = '''
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
''';
return fileContents.replaceAll(plistEnd, plistWithKey);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment