diff --git a/.fvmrc b/.fvmrc index f6ff4f3..827b556 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.44.6" -} \ No newline at end of file + "flutter": "3.47.5" +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45a3c0c..0a5b855 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig @@ -70,6 +71,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig @@ -103,6 +105,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig @@ -133,6 +136,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig @@ -151,6 +155,17 @@ jobs: flutter pub get flutter build macos --debug + - name: Build macOS example (Release) + run: | + set -o pipefail + cd example + build_log="$RUNNER_TEMP/flutter-macos-release.log" + flutter build macos --release 2>&1 | tee "$build_log" + if grep -Fq 'different framework names for different architectures' "$build_log"; then + echo 'Flutter reported inconsistent code asset framework names.' >&2 + exit 1 + fi + build-linux: runs-on: ubuntu-latest @@ -169,6 +184,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig @@ -200,6 +216,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml index 7855225..8fa230b 100644 --- a/.github/workflows/manual-publish.yml +++ b/.github/workflows/manual-publish.yml @@ -21,6 +21,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig diff --git a/.github/workflows/pub-publish.yml b/.github/workflows/pub-publish.yml index 57e52d5..22c5ce2 100644 --- a/.github/workflows/pub-publish.yml +++ b/.github/workflows/pub-publish.yml @@ -23,6 +23,7 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable + flutter-version-file: .fvmrc cache: true - name: Setup Zig diff --git a/CHANGELOG.md b/CHANGELOG.md index 362d540..1166b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Releases +## Unreleased + +### Changed + +* Pin development to Flutter 3.47.5 and update the minimum SDK constraints for + the current native-assets dependencies. +* Use the pinned Flutter version in CI and verify the macOS Release build does + not report inconsistent code asset framework names. +* Upgrade `code_assets`, `hooks`, and `ffigen`; move `test` to the newest + version compatible with the `flutter_test` SDK pin. +* Raise the example app's macOS deployment target to 12.0 for Flutter 3.47. +* Document how to compare this customized package with a freshly generated + `package_ffi` template while preserving Android `content://` support. + +--- + ## 0.0.4 * Hash Android `content://` URIs through `ContentResolver.openFileDescriptor` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 382b082..14bf387 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,13 +2,43 @@ ## Setup -Use Flutter stable, Zig, and the platform SDKs for the targets you want to -build. The CI Zig version is defined in +Use the Flutter version in `.fvmrc`, Zig, and the platform SDKs for the targets +you want to build. The CI Zig version is defined in `.github/actions/setup-zig/action.yml`. If you do not use FVM locally, replace `fvm flutter` and `fvm dart` with `flutter` and `dart`. +## Flutter Template Updates + +The package starts from Flutter's `package_ffi` template, with a custom Zig +build hook and an Android plugin layer for `content://` access. Flutter updates +the templates inside each SDK release; there is no safe in-place command that +merges every upstream template change into this customized package. + +To review a template update after changing the Flutter version in `.fvmrc`, +generate a clean copy with the same package name. Compare only the relevant +template files, not the entire repository (which also contains build outputs, +prebuilts, and custom platform code): + +```bash +template_dir="$(mktemp -d)" +fvm flutter create --template=package_ffi --project-name flutter_file_hash \ + --no-pub "$template_dir/flutter_file_hash" +for file in pubspec.yaml analysis_options.yaml ffigen.yaml hook/build.dart \ + example/pubspec.yaml example/analysis_options.yaml \ + example/macos/Runner.xcodeproj/project.pbxproj; do + diff -u "$template_dir/flutter_file_hash/$file" "$file" || true +done +``` + +Extend the file list when reviewing another platform's generated project. +Keep the custom `hook/build.dart`, Android `FlutterFileHashPlugin`, JNI/CMake +bridge, prebuilt layout, and handwritten FFI bindings intact unless the +corresponding package behavior is deliberately being changed. `.metadata` +records Flutter project metadata; it is not a general dependency or template +synchronizer. + Initialize the Zig submodule: ```bash diff --git a/README.md b/README.md index b9d36a1..b0334b7 100644 --- a/README.md +++ b/README.md @@ -376,12 +376,13 @@ directly and avoid that extra copy. ## FFI/native-assets Template Usage -`flutter_file_hash` uses Flutter's modern `plugin_ffi`/native-assets path for -the native hash core. The public Dart API talks to one Zig native core through -the C ABI; platform code is used only where the operating system does not expose -a regular file path to Dart. +`flutter_file_hash` uses Flutter's `package_ffi` build-hook/native-assets path +for the Zig hash core. Android also has a small Flutter plugin layer because +`ContentResolver` is needed to open `content://` URIs. The public Dart API calls +the same Zig C ABI on every platform. -macOS release builds can print a native-assets packaging warning like: +Flutter versions before 3.47.0 could print this warning during macOS release +builds: ```text Code asset "package:flutter_file_hash/src/zig_files_hash_bindings.dart" has @@ -389,14 +390,12 @@ different framework names for different architectures. Picking "zig_files_hash_c_api.framework" and ignoring "zig_files_hash_c_api1.framework". ``` -This comes from Flutter's macOS `code_assets` packaging path when it combines -multiple architectures into one app bundle. The generated app bundle still -contains the expected universal native framework, so the warning can be ignored. +Flutter fixed multi-architecture code asset framework naming in 3.47.0 +([Flutter #185640](https://github.com/flutter/flutter/pull/185640)). A macOS +Release build with Flutter 3.47.5 completed without this warning. -The strategy is to keep `plugin_ffi`/native-assets for the Zig core and adopt -upstream Flutter fixes when macOS native-assets packaging improves. Android -platform code remains limited to opening provider URIs, as described in Android -URI Streams. +The Android plugin opens provider URIs and passes file descriptors or streams +to the shared Zig core, as described in Android URI Streams. ## Performance @@ -435,4 +434,5 @@ Contributions are welcome. MIT. See [LICENSE](LICENSE) for details. -Built on Flutter's `plugin_ffi`/native-assets template. +Built with Flutter's `package_ffi` build hooks and an Android plugin for +`content://` access. diff --git a/analysis_options.yaml b/analysis_options.yaml index a5744c1..756c0f4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,7 @@ +analyzer: + exclude: + - build/** + - android/** include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at diff --git a/example/.fvmrc b/example/.fvmrc new file mode 100644 index 0000000..827b556 --- /dev/null +++ b/example/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.47.5" +} diff --git a/example/.gitignore b/example/.gitignore index 3820a95..772c097 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -43,3 +43,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +# FVM Version Cache +.fvm/ diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 0d29021..bf8d421 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -7,6 +7,15 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + exclude: + - build/** + - android/** + - ios/** + - web/** + - windows/** + - macos/** + - linux/** include: package:flutter_lints/flutter.yaml linter: diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 92aa608..1e7bc8f 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -487,7 +487,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -538,7 +538,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/lib/main.dart b/example/lib/main.dart index 0c5b734..ffcbf64 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -934,9 +934,8 @@ class _HashDemoPageState extends State { } void _showMessage(String message) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text(message))); + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text(message))); } } @@ -954,17 +953,14 @@ class _Header extends StatelessWidget { children: [ Text( 'File Hash', - style: Theme.of(context).textTheme.headlineSmall?.copyWith( - color: palette.text, - fontWeight: FontWeight.w800, - ), + style: Theme.of(context).textTheme.headlineSmall + ?.copyWith(color: palette.text, fontWeight: FontWeight.w800), ), const SizedBox(height: 4), Text( 'Native streaming hash (MD5 / SHA / XXH3 / BLAKE3)', - style: Theme.of( - context, - ).textTheme.bodyMedium?.copyWith(color: palette.muted), + style: Theme.of(context).textTheme.bodyMedium + ?.copyWith(color: palette.muted), ), ], ), @@ -1005,10 +1001,8 @@ class _CardPanel extends StatelessWidget { children: [ Text( title, - style: Theme.of(context).textTheme.titleMedium?.copyWith( - color: palette.text, - fontWeight: FontWeight.w700, - ), + style: Theme.of(context).textTheme.titleMedium + ?.copyWith(color: palette.text, fontWeight: FontWeight.w700), ), const SizedBox(height: 10), ...children, @@ -1248,17 +1242,14 @@ class _FileDetails extends StatelessWidget { children: [ Text( file.name, - style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: palette.text, - fontWeight: FontWeight.w600, - ), + style: Theme.of(context).textTheme.bodyMedium + ?.copyWith(color: palette.text, fontWeight: FontWeight.w600), ), const SizedBox(height: 4), SelectableText( '${_fileSizeLabel(file.size)} - ${file.displayPath}', - style: Theme.of( - context, - ).textTheme.bodySmall?.copyWith(color: palette.muted), + style: Theme.of(context).textTheme.bodySmall + ?.copyWith(color: palette.muted), ), ], ); @@ -1285,9 +1276,8 @@ class _DigestResult extends StatelessWidget { children: [ Text( 'Result', - style: Theme.of( - context, - ).textTheme.labelSmall?.copyWith(color: palette.muted), + style: Theme.of(context).textTheme.labelSmall + ?.copyWith(color: palette.muted), ), const SizedBox(height: 6), SelectableText(digest, style: _monoStyle(context, palette)), @@ -1295,9 +1285,8 @@ class _DigestResult extends StatelessWidget { const SizedBox(height: 8), Text( _formatMs(elapsedMs), - style: Theme.of( - context, - ).textTheme.labelSmall?.copyWith(color: palette.muted), + style: Theme.of(context).textTheme.labelSmall + ?.copyWith(color: palette.muted), ), ], ], diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index a97c38d..c998596 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -471,7 +471,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -553,7 +553,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -603,7 +603,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/example/pubspec.lock b/example/pubspec.lock index cc099c9..4b568af 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: code_assets - sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8 + sha256: "828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "2.1.0" collection: dependency: transitive description: @@ -187,10 +187,10 @@ packages: dependency: transitive description: name: hooks - sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba" + sha256: eaac480a35ec0814146c2c48d96aaa829e0e44a7662c88ae84c9edf4bc35651f url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.2.0" http: dependency: transitive description: @@ -251,10 +251,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" url: "https://pub.dev" source: hosted - version: "0.12.19" + version: "0.12.20" material_color_utilities: dependency: transitive description: @@ -267,10 +267,10 @@ packages: dependency: transitive description: name: meta - sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" path: dependency: transitive description: @@ -299,10 +299,10 @@ packages: dependency: transitive description: name: record_use - sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + sha256: "1cb8564af8d43b464294411db9217f5ec04891c6f22ee2c32d73ae05e88a6bd2" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "1.1.1" sky_engine: dependency: transitive description: flutter @@ -352,10 +352,10 @@ packages: dependency: transitive description: name: test_api - sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" + sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11" url: "https://pub.dev" source: hosted - version: "0.7.11" + version: "0.7.12" typed_data: dependency: transitive description: @@ -368,10 +368,10 @@ packages: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: "92b9910f66ed1057fd4da7b040ae7c74cafacf885bdc81be496928d5049b032d" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.3" vm_service: dependency: transitive description: @@ -397,5 +397,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.12.2 <4.0.0" - flutter: ">=3.44.0" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index bc69a9d..9f5638b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ^3.12.2 + sdk: ^3.13.0 # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pubspec.yaml b/pubspec.yaml index 8817642..0d5c5fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 0.0.4 repository: https://github.com/Preeternal/flutter-file-hash environment: - sdk: ^3.12.2 - flutter: '>=3.44.0' + sdk: ^3.13.0 + flutter: '>=3.47.0' platforms: android: @@ -15,18 +15,18 @@ platforms: windows: dependencies: - code_assets: ^1.2.1 + code_assets: ^2.1.0 ffi: ^2.1.4 flutter: sdk: flutter - hooks: ^2.0.2 + hooks: ^2.2.0 dev_dependencies: - ffigen: ^20.1.1 + ffigen: ^22.0.0 flutter_test: sdk: flutter flutter_lints: ^6.0.0 - test: ^1.28.0 + test: ^1.31.1 flutter: plugin: