Skip to content

Commit 26db75e

Browse files
authored
Force plugin transitive dependencies to an ARC compatible version (flutter#124527)
Cherry-pick flutter#124349 onto stable. CP request at flutter#124529
1 parent 6e98282 commit 26db75e

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

dev/devicelab/lib/tasks/plugin_tests.dart

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,19 @@ class $dartPluginClass {
201201
if (!podspecContent.contains(versionString)) {
202202
throw TaskResult.failure('Update this test to match plugin minimum $target deployment version');
203203
}
204-
podspecContent = podspecContent.replaceFirst(
205-
versionString,
206-
target == 'ios'
207-
? "s.platform = :ios, '10.0'"
208-
: "s.platform = :osx, '10.8'"
209-
);
204+
// Add transitive dependency on AppAuth 1.6 targeting iOS 8 and macOS 10.9, which no longer builds in Xcode
205+
// to test the version is forced higher and builds.
206+
const String iosContent = '''
207+
s.platform = :ios, '10.0'
208+
s.dependency 'AppAuth', '1.6.0'
209+
''';
210+
211+
const String macosContent = '''
212+
s.platform = :osx, '10.8'
213+
s.dependency 'AppAuth', '1.6.0'
214+
''';
215+
216+
podspecContent = podspecContent.replaceFirst(versionString, target == 'ios' ? iosContent : macosContent);
210217
podspec.writeAsStringSync(podspecContent, flush: true);
211218
}
212219

@@ -226,7 +233,8 @@ class $dartPluginClass {
226233
// but the range of supported deployment target versions is 9.0 to 14.0.99.
227234
//
228235
// (or "The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET'"...)
229-
if (buildOutput.contains('the range of supported deployment target versions')) {
236+
if (buildOutput.contains('is set to 10.0, but the range of supported deployment target versions') ||
237+
buildOutput.contains('is set to 10.8, but the range of supported deployment target versions')) {
230238
throw TaskResult.failure('Minimum plugin version warning present');
231239
}
232240

@@ -244,15 +252,23 @@ class $dartPluginClass {
244252
if (podsProjectContent.contains('IPHONEOS_DEPLOYMENT_TARGET = 10')) {
245253
throw TaskResult.failure('Plugin build setting IPHONEOS_DEPLOYMENT_TARGET not removed');
246254
}
255+
// Transitive dependency AppAuth targeting too-low 8.0 was not fixed.
256+
if (podsProjectContent.contains('IPHONEOS_DEPLOYMENT_TARGET = 8')) {
257+
throw TaskResult.failure('Transitive dependency build setting IPHONEOS_DEPLOYMENT_TARGET=8 not removed');
258+
}
247259
if (!podsProjectContent.contains(r'"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "$(inherited) i386";')) {
248260
throw TaskResult.failure(r'EXCLUDED_ARCHS is not "$(inherited) i386"');
249261
}
250-
}
251-
252-
// Same for macOS deployment target, but 10.8.
253-
// The plugintest target should not have MACOSX_DEPLOYMENT_TARGET set.
254-
if (target == 'macos' && podsProjectContent.contains('MACOSX_DEPLOYMENT_TARGET = 10.8')) {
255-
throw TaskResult.failure('Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed');
262+
} else if (target == 'macos') {
263+
// Same for macOS deployment target, but 10.8.
264+
// The plugintest target should not have MACOSX_DEPLOYMENT_TARGET set.
265+
if (podsProjectContent.contains('MACOSX_DEPLOYMENT_TARGET = 10.8')) {
266+
throw TaskResult.failure('Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed');
267+
}
268+
// Transitive dependency AppAuth targeting too-low 10.9 was not fixed.
269+
if (podsProjectContent.contains('MACOSX_DEPLOYMENT_TARGET = 10.9')) {
270+
throw TaskResult.failure('Transitive dependency build setting MACOSX_DEPLOYMENT_TARGET=10.9 not removed');
271+
}
256272
}
257273
}
258274
}

packages/flutter_tools/bin/podhelper.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def flutter_additional_ios_build_settings(target)
3434
# [target.deployment_target] is a [String] formatted as "8.0".
3535
inherit_deployment_target = target.deployment_target[/\d+/].to_i < 11
3636

37+
# ARC code targeting iOS 8 does not build on Xcode 14.3.
38+
force_to_arc_supported_min = target.deployment_target[/\d+/].to_i < 9
39+
3740
# This podhelper script is at $FLUTTER_ROOT/packages/flutter_tools/bin.
3841
# Add search paths from $FLUTTER_ROOT/bin/cache/artifacts/engine.
3942
artifacts_dir = File.join('..', '..', '..', '..', 'bin', 'cache', 'artifacts', 'engine')
@@ -62,6 +65,9 @@ def flutter_additional_ios_build_settings(target)
6265
build_configuration.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = '-'
6366
end
6467

68+
# ARC code targeting iOS 8 does not build on Xcode 14.3. Force to at least iOS 9.
69+
build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0' if force_to_arc_supported_min
70+
6571
# Skip other updates if it's not a Flutter plugin (transitive dependency).
6672
next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' }
6773

@@ -99,12 +105,14 @@ def flutter_additional_ios_build_settings(target)
99105
def flutter_additional_macos_build_settings(target)
100106
return unless target.platform_name == :osx
101107

102-
# Return if it's not a Flutter plugin (transitive dependency).
103-
return unless target.dependencies.any? { |dependency| dependency.name == 'FlutterMacOS' }
104-
105108
# [target.deployment_target] is a [String] formatted as "10.8".
106109
deployment_target_major, deployment_target_minor = target.deployment_target.match(/(\d+).?(\d*)/).captures
107110

111+
# ARC code targeting macOS 10.10 does not build on Xcode 14.3.
112+
force_to_arc_supported_min = !target.deployment_target.blank? &&
113+
(deployment_target_major.to_i < 10) ||
114+
(deployment_target_major.to_i == 10 && deployment_target_minor.to_i < 11)
115+
108116
# Suppress warning when pod supports a version lower than the minimum supported by the latest stable version of Xcode (currently 10.14).
109117
# This warning is harmless but confusing--it's not a bad thing for dependencies to support a lower version.
110118
inherit_deployment_target = !target.deployment_target.blank? &&
@@ -123,6 +131,12 @@ def flutter_additional_macos_build_settings(target)
123131
end
124132

125133
target.build_configurations.each do |build_configuration|
134+
# ARC code targeting macOS 10.10 does not build on Xcode 14.3. Force to at least macOS 10.11.
135+
build_configuration.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.11' if force_to_arc_supported_min
136+
137+
# Skip other updates if it's not a Flutter plugin (transitive dependency).
138+
next unless target.dependencies.any? { |dependency| dependency.name == 'FlutterMacOS' }
139+
126140
# Profile can't be derived from the CocoaPods build configuration. Use release framework (for linking only).
127141
configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir
128142
build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS'] = "\"#{configuration_engine_dir}\" $(inherited)"

0 commit comments

Comments
 (0)