Set template and migrate apps to iOS 11 minimum (#101963)

This commit is contained in:
Jenn Magder
2022-04-15 11:34:08 -07:00
committed by GitHub
parent e565ba0456
commit 1756ccc541
86 changed files with 235 additions and 177 deletions

View File

@@ -181,7 +181,7 @@ def flutter_install_ios_engine_pod(ios_application_path = nil)
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'

View File

@@ -258,7 +258,7 @@ class AOTSnapshotter {
// When the minimum version is updated, remember to update
// template MinimumOSVersion.
// https://github.com/flutter/flutter/pull/62902
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
if (sdkRoot != null) ...<String>[
'-isysroot',
sdkRoot,

View File

@@ -602,9 +602,9 @@ Future<void> _createStubAppFramework(File outputFile, Environment environment,
'-fembed-bitcode-marker',
// Keep version in sync with AOTSnapshotter flag
if (environmentType == EnvironmentType.physical)
'-miphoneos-version-min=9.0'
'-miphoneos-version-min=11.0'
else
'-miphonesimulator-version-min=9.0',
'-miphonesimulator-version-min=11.0',
'-Xlinker', '-rpath', '-Xlinker', '@executable_path/Frameworks',
'-Xlinker', '-rpath', '-Xlinker', '@loader_path/Frameworks',
'-install_name', '@rpath/App.framework/App',

View File

@@ -284,7 +284,7 @@ LICENSE
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :http => '${_cache.storageBaseUrl}/flutter_infra_release/flutter/${_cache.engineRevision}/$artifactsMode/artifacts.zip' }
s.documentation_url = 'https://flutter.dev/docs'
s.platform = :ios, '9.0'
s.platform = :ios, '11.0'
s.vendored_frameworks = 'Flutter.xcframework'
end
''';

View File

@@ -759,7 +759,7 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
final List<Map<String, Object?>> iosPlugins = _extractPlatformMaps(methodChannelPlugins, IOSPlugin.kConfigKey);
final Map<String, Object> context = <String, Object>{
'os': 'ios',
'deploymentTarget': '9.0',
'deploymentTarget': '11.0',
'framework': 'Flutter',
'methodChannelPlugins': iosPlugins,
};

View File

@@ -12,9 +12,11 @@ class DeploymentTargetMigration extends ProjectMigrator {
IosProject project,
super.logger,
) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile,
_podfile = project.podfile,
_appFrameworkInfoPlist = project.appFrameworkInfoPlist;
final File _xcodeProjectInfoFile;
final File _podfile;
final File _appFrameworkInfoPlist;
@override
@@ -31,33 +33,58 @@ class DeploymentTargetMigration extends ProjectMigrator {
logger.printTrace('AppFrameworkInfo.plist not found, skipping minimum OS version migration.');
}
if (_podfile.existsSync()) {
processFileLines(_podfile);
} else {
logger.printTrace('Podfile not found, skipping global platform version migration.');
}
return true;
}
@override
String migrateFileContents(String fileContents) {
const String minimumOSVersionOriginal = '''
const String minimumOSVersionOriginal8 = '''
<key>MinimumOSVersion</key>
<string>8.0</string>
''';
const String minimumOSVersionReplacement = '''
const String minimumOSVersionOriginal9 = '''
<key>MinimumOSVersion</key>
<string>9.0</string>
''';
const String minimumOSVersionReplacement = '''
<key>MinimumOSVersion</key>
<string>11.0</string>
''';
return fileContents.replaceAll(minimumOSVersionOriginal, minimumOSVersionReplacement);
return fileContents
.replaceAll(minimumOSVersionOriginal8, minimumOSVersionReplacement)
.replaceAll(minimumOSVersionOriginal9, minimumOSVersionReplacement);
}
@override
String? migrateLine(String line) {
const String deploymentTargetOriginal = 'IPHONEOS_DEPLOYMENT_TARGET = 8.0;';
const String deploymentTargetReplacement = 'IPHONEOS_DEPLOYMENT_TARGET = 9.0;';
if (line.contains(deploymentTargetOriginal)) {
// Xcode project file changes.
const String deploymentTargetOriginal8 = 'IPHONEOS_DEPLOYMENT_TARGET = 8.0;';
const String deploymentTargetOriginal9 = 'IPHONEOS_DEPLOYMENT_TARGET = 9.0;';
// Podfile changes.
const String podfilePlatformVersionOriginal = "platform :ios, '9.0'";
if (line.contains(deploymentTargetOriginal8)
|| line.contains(deploymentTargetOriginal9)
|| line.contains(podfilePlatformVersionOriginal)) {
if (!migrationRequired) {
// Only print for the first discovered change found.
logger.printStatus('Updating minimum iOS deployment target from 8.0 to 9.0.');
logger.printStatus('Updating minimum iOS deployment target to 11.0.');
}
return line.replaceAll(deploymentTargetOriginal, deploymentTargetReplacement);
const String deploymentTargetReplacement = 'IPHONEOS_DEPLOYMENT_TARGET = 11.0;';
const String podfilePlatformVersionReplacement = "platform :ios, '11.0'";
return line
.replaceAll(deploymentTargetOriginal8, deploymentTargetReplacement)
.replaceAll(deploymentTargetOriginal9, deploymentTargetReplacement)
.replaceAll(podfilePlatformVersionOriginal, podfilePlatformVersionReplacement);
}
return line;

View File

@@ -283,7 +283,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -360,7 +360,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -409,7 +409,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

View File

@@ -272,7 +272,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -352,7 +352,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -401,7 +401,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

View File

@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>

View File

@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -15,6 +15,6 @@ This pod vends the iOS Flutter engine framework. It is compatible with applicati
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.documentation_url = 'https://flutter.dev/docs'
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
s.vendored_frameworks = 'Flutter.xcframework'
end

View File

@@ -283,7 +283,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -359,7 +359,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -408,7 +408,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;

View File

@@ -1,4 +1,4 @@
platform :ios, '9.0'
platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>

View File

@@ -127,7 +127,7 @@ def install_flutter_application_pod(flutter_application_path)
# Create a dummy dylib.
FileUtils.mkdir_p(app_framework_dir)
sdk_path = `xcrun --sdk iphoneos --show-sdk-path`.strip
`echo "static const int Moo = 88;" | xcrun clang -x c -arch arm64 -dynamiclib -miphoneos-version-min=9.0 -isysroot "#{sdk_path}" -o "#{app_framework_dylib}" -`
`echo "static const int Moo = 88;" | xcrun clang -x c -arch arm64 -dynamiclib -miphoneos-version-min=11.0 -isysroot "#{sdk_path}" -o "#{app_framework_dylib}" -`
end
# Keep pod and script phase paths relative so they can be checked into source control.

View File

@@ -7,7 +7,7 @@ Pod::Spec.new do |s|
s.license = { :type => 'BSD' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :path => '.' }
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
s.vendored_frameworks = 'App.framework'
s.dependency 'Flutter'
end

View File

@@ -28,7 +28,7 @@ const FakeCommand kARMCheckCommand = FakeCommand(
);
const List<String> kDefaultClang = <String>[
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-dynamiclib',
@@ -220,7 +220,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-fembed-bitcode',
@@ -234,7 +234,7 @@ void main() {
'clang',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-dynamiclib',
@@ -297,7 +297,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-c',
@@ -355,7 +355,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-c',
@@ -410,7 +410,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/sdk',
'-c',

View File

@@ -471,7 +471,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/iPhoneOS.sdk',
// Contains bitcode flag.
@@ -486,7 +486,7 @@ void main() {
'clang',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/iPhoneOS.sdk',
'-dynamiclib',
@@ -547,7 +547,7 @@ void main() {
'cc',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/iPhoneOS.sdk',
// Contains bitcode flag.
@@ -562,7 +562,7 @@ void main() {
'clang',
'-arch',
'arm64',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-isysroot',
'path/to/iPhoneOS.sdk',
'-dynamiclib',

View File

@@ -23,7 +23,7 @@ final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment:
const List<String> _kSharedConfig = <String>[
'-dynamiclib',
'-fembed-bitcode-marker',
'-miphoneos-version-min=9.0',
'-miphoneos-version-min=11.0',
'-Xlinker',
'-rpath',
'-Xlinker',
@@ -85,7 +85,7 @@ void main() {
'.tmp_rand0', 'flutter_tools_stub_source.rand0', 'debug_app.cc')),
'-dynamiclib',
'-fembed-bitcode-marker',
'-miphonesimulator-version-min=9.0',
'-miphonesimulator-version-min=11.0',
'-Xlinker',
'-rpath',
'-Xlinker',

View File

@@ -497,6 +497,7 @@ keep this 3
late FakeIosProject project;
late File xcodeProjectInfoFile;
late File appFrameworkInfoPlist;
late File podfile;
setUp(() {
memoryFileSystem = MemoryFileSystem();
@@ -507,6 +508,9 @@ keep this 3
appFrameworkInfoPlist = memoryFileSystem.file('AppFrameworkInfo.plist');
project.appFrameworkInfoPlist = appFrameworkInfoPlist;
podfile = memoryFileSystem.file('Podfile');
project.podfile = podfile;
});
testWithoutContext('skipped if files are missing', () {
@@ -517,24 +521,30 @@ keep this 3
expect(iosProjectMigration.migrate(), isTrue);
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(appFrameworkInfoPlist.existsSync(), isFalse);
expect(podfile.existsSync(), isFalse);
expect(testLogger.traceText, contains('Xcode project not found, skipping iOS deployment target version migration'));
expect(testLogger.traceText, contains('AppFrameworkInfo.plist not found, skipping minimum OS version migration'));
expect(testLogger.traceText, contains('Podfile not found, skipping global platform version migration'));
expect(testLogger.statusText, isEmpty);
});
testWithoutContext('skipped if nothing to upgrade', () {
const String xcodeProjectInfoFileContents = 'IPHONEOS_DEPLOYMENT_TARGET = 9.0;';
const String xcodeProjectInfoFileContents = 'IPHONEOS_DEPLOYMENT_TARGET = 11.0;';
xcodeProjectInfoFile.writeAsStringSync(xcodeProjectInfoFileContents);
const String appFrameworkInfoPlistContents = '''
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
''';
appFrameworkInfoPlist.writeAsStringSync(appFrameworkInfoPlistContents);
final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync();
const String podfileFileContents = "# platform :ios, '11.0'";
podfile.writeAsStringSync(podfileFileContents);
final DateTime podfileLastModified = podfile.lastModifiedSync();
final DeploymentTargetMigration iosProjectMigration = DeploymentTargetMigration(
project,
testLogger,
@@ -544,11 +554,13 @@ keep this 3
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
expect(appFrameworkInfoPlist.readAsStringSync(), appFrameworkInfoPlistContents);
expect(podfile.lastModifiedSync(), podfileLastModified);
expect(podfile.readAsStringSync(), podfileFileContents);
expect(testLogger.statusText, isEmpty);
});
testWithoutContext('Xcode project is migrated to minimum version 8.0', () {
testWithoutContext('Xcode project is migrated to 11', () {
xcodeProjectInfoFile.writeAsStringSync('''
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@@ -556,6 +568,7 @@ keep this 3
ONLY_ACTIVE_ARCH = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
''');
appFrameworkInfoPlist.writeAsStringSync('''
@@ -567,8 +580,15 @@ keep this 3
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
</dict>
</plist>
''');
podfile.writeAsStringSync('''
# platform :ios, '9.0'
platform :ios, '9.0'
''');
final DeploymentTargetMigration iosProjectMigration = DeploymentTargetMigration(
@@ -579,11 +599,12 @@ keep this 3
expect(xcodeProjectInfoFile.readAsStringSync(), '''
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
''');
expect(appFrameworkInfoPlist.readAsStringSync(), '''
@@ -594,12 +615,19 @@ keep this 3
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
</dict>
</plist>
''');
expect(podfile.readAsStringSync(), '''
# platform :ios, '11.0'
platform :ios, '11.0'
''');
// Only print once even though 2 lines were changed.
expect('Updating minimum iOS deployment target from 8.0 to 9.0'.allMatches(testLogger.statusText).length, 1);
expect('Updating minimum iOS deployment target to 11.0'.allMatches(testLogger.statusText).length, 1);
});
});
@@ -809,6 +837,9 @@ class FakeIosProject extends Fake implements IosProject {
@override
File defaultHostInfoPlist = MemoryFileSystem.test().file('defaultHostInfoPlist');
@override
File podfile = MemoryFileSystem.test().file('Podfile');
}
class FakeIOSMigrator extends ProjectMigrator {