From df2b36045302d74c2dcb97d79a77b3935aa7f00a Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Tue, 5 Mar 2024 14:58:15 +0100 Subject: [PATCH] Do not shorten native assets framework names (#144568) Previously the name was shortened to 15 characters, which doesn't seem to be necessary. [CFBundleName](https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundlename) documentation mentions 15 character length, but that does not seem to be relevant to framework bundles. Flutter plugins already have framework bundles with names longer than 15 characters and it is not causing any issues. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes --- .../isolated/native_assets/macos/native_assets_host.dart | 9 --------- .../isolated/macos/native_assets_host_test.dart | 8 ++++---- .../integration.shard/isolated/native_assets_test.dart | 6 +++--- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart b/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart index b0bfb0e7e7c..9f3c42521d8 100644 --- a/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart +++ b/packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart @@ -165,9 +165,6 @@ Future cCompilerConfigMacOS() async { /// (A–Z, a–z, and 0–9), hyphens (-), and periods (.). /// https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier /// -/// This name can contain up to 15 characters. -/// https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundlename -/// /// The [alreadyTakenNames] are used to ensure that the framework name does not /// conflict with previously chosen names. Uri frameworkUri(String fileName, Set alreadyTakenNames) { @@ -185,13 +182,7 @@ Uri frameworkUri(String fileName, Set alreadyTakenNames) { fileName = fileName.replaceFirst('lib', ''); } fileName = fileName.replaceAll(RegExp(r'[^A-Za-z0-9_-]'), ''); - if (fileName.length > 15) { - fileName = fileName.substring(0, 15); - } if (alreadyTakenNames.contains(fileName)) { - if (fileName.length > 12) { - fileName = fileName.substring(0, 12); - } final String prefixName = fileName; for (int i = 1; i < 1000; i++) { fileName = '$prefixName$i'; diff --git a/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_host_test.dart b/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_host_test.dart index ad8898ce1bb..4e1c3b62c88 100644 --- a/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_host_test.dart +++ b/packages/flutter_tools/test/general.shard/isolated/macos/native_assets_host_test.dart @@ -34,7 +34,7 @@ void main() { ); expect( frameworkUri('libatoolongfilenameforaframework.dylib', {}), - equals(Uri.file('atoolongfilenam.framework/atoolongfilenam')), + equals(Uri.file('atoolongfilenameforaframework.framework/atoolongfilenameforaframework')), ); }); @@ -54,15 +54,15 @@ void main() { ); expect( frameworkUri('libatoolongfilenameforaframework.dylib', alreadyTakenNames), - equals(Uri.file('atoolongfilenam.framework/atoolongfilenam')), + equals(Uri.file('atoolongfilenameforaframework.framework/atoolongfilenameforaframework')), ); expect( frameworkUri('libatoolongfilenameforaframework.dylib', alreadyTakenNames), - equals(Uri.file('atoolongfile1.framework/atoolongfile1')), + equals(Uri.file('atoolongfilenameforaframework1.framework/atoolongfilenameforaframework1')), ); expect( frameworkUri('libatoolongfilenameforaframework.dylib', alreadyTakenNames), - equals(Uri.file('atoolongfile2.framework/atoolongfile2')), + equals(Uri.file('atoolongfilenameforaframework2.framework/atoolongfilenameforaframework2')), ); }); } diff --git a/packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart b/packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart index 505f4fdadc9..eb5f9f1e726 100644 --- a/packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart +++ b/packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart @@ -305,7 +305,7 @@ void expectDylibIsBundledMacOS(Directory appDirectory, String buildMode) { // Resources/ // Info.plist // Current -> A - final String frameworkName = packageName.substring(0, 15); + const String frameworkName = packageName; final Directory frameworkDir = frameworksFolder.childDirectory('$frameworkName.framework'); final Directory versionsDir = frameworkDir.childDirectory('Versions'); @@ -330,7 +330,7 @@ void expectDylibIsBundledIos(Directory appDirectory, String buildMode) { expect(appBundle, exists); final Directory frameworksFolder = appBundle.childDirectory('Frameworks'); expect(frameworksFolder, exists); - final String frameworkName = packageName.substring(0, 15); + const String frameworkName = packageName; final File dylib = frameworksFolder .childDirectory('$frameworkName.framework') .childFile(frameworkName); @@ -409,7 +409,7 @@ void expectDylibIsBundledAndroid(Directory appDirectory, String buildMode) { void expectDylibIsBundledWithFrameworks(Directory appDirectory, String buildMode, String os) { final Directory frameworksFolder = appDirectory.childDirectory('build/$os/framework/${buildMode.upperCaseFirst()}'); expect(frameworksFolder, exists); - final String frameworkName = packageName.substring(0, 15); + const String frameworkName = packageName; final File dylib = frameworksFolder .childDirectory('$frameworkName.framework') .childFile(frameworkName);