[ffigen] Gemini's friction log
Maintainers usually reply within 2 days
@liamappelbe is already working on this.
Since Dec 2, 2026.
Assessment
This issue has not been assessed yet.
Description
This is an AI generated summary of all the issues Gemini has run into while using FFIgen. I haven't fully reviewed the contents. I need to go through these in detail and triage them/file separate issues. I'm pasting it into an issue to make review easier for myself.
FFIgen Usage & Tooling Improvements
Executive Summary
A review of package:ffigen across consumer, migration, and maintenance workflows surfaced five dominant themes driving developer and coding-agent friction:
- Silent misconfigurations as the primary failure mode: FFIgen frequently exits with code
0on broken configurations, including bareasset-idvalues that disagree withCBuilder.library, unknown YAML keys logged at[SEVERE],structs.excludeoverridden by transitive dependencies, pre-rename vs post-rename filter mismatches, uncompilable Dart from mismatchedstructs/unionsopacity, silent no-ops inInput(compilerOptions: null, appendCompilerOptions: true), and silent ABI corruption whenappendCompilerOptions: falsepairs withignoreSourceErrors: true. - Opaque Clang /
libclangdiscovery and OS platform traps: Missing diagnostic logs for resolvedlibclangpaths, versions, and-resource-dirvalues make silent Homebrew-vs-Xcode shadowing, outdated Linux/macOS search paths, cross-toolchain header mismatches, Clang 22/23ElaboratedTypeAST changes, Linuxxcrun/Objective-C crashes, and host<pthread.h>header leakage costly to diagnose. - Build-hook coupling and packaging hazards: Test-only
pkgs/ffigen/hook/build.dartleaked into publishedffigen 23.0.0, couples native compilation into pure-Dart CLI and unit-test runs (breaking entirely whenswiftlyhijacksclangand adding 1.3s to 2.6s overhead), emits an invalidbuildSwiftiOS Simulator triple, produces opaque rebuild errors, and triggers chicken-and-egg.mcrashes underdart run tool/ffigen.dartin greenfield consumer apps. - Missing check mode and extreme log noise:
FfiGeneratorlacks a first-class dry-run /--set-exit-if-changedcheck mode, while internal header-path, hash, and CWD-formatting couplings break temp-dir diffing. Routine runs emit 110 to 898 lines of[WARNING]/[SEVERE]noise (including warnings on excluded Foundation declarations) that truncate real failures and push consumers to mute logs. - API, generated-code, regeneration, and documentation drift: Remaining
Visitorergonomics gaps, symbol collisions (Declaration,Symbol,#2850struct-field scoping), pure-ObjC@ffi.DefaultAssetlazy loading traps,dart analyze --fatal-infosfailures on freshly generated bindings, fragmented monorepo regeneration entrypoints, workspace-excludedexample/*drift, and stale docs (pkgs/ffigen/test/README.md,checkOsVersion,Func.exposeSymbolAddress, legacy YAML bias) repeatedly trip both humans and agents.
Suggested Improvements
P0: High-Blast-Radius Silent Failures, Toolchain Discovery & Build-Hook Isolation
- Validate
asset-id/defaultAssetformat againstCBuilder.libraryconventions: Validate inconfig.dartandwriter.dartthatassetId/defaultAssetconforms to Dart'spackage:asset ID URI convention. Emit a prominent warning or error on bare paths (such assample_c.dart), explicitly noting thatCBuilder.libraryautomatically prependspackage:<package_name>/. - Fail fast on unknown YAML keys and enforce filter, opacity, and compiler-option invariants: Exit non-zero on unknown YAML keys, warn when
include/excluderules match zero declarations (noting pre-rename matching) or when excluded structs are emitted viadependency-only: full, and fail or auto-opaqueffi.Unionfields whose struct member isffi.Opaque. Assert or warn onInput(compilerOptions: null, appendCompilerOptions: true)and onignoreSourceErrors: truepaired with missing system headers orappendCompilerOptions: falseto prevent silent ABI corruption. - Make
libclangdiscovery transparent, modern, self-paired, and unified across pipelines: Log the resolvedlibclangpath,clang_getClangVersion(),-resource-dir, and unsupported version warnings (> 22), while fixingmacOsDylibLocations, enforcing same-toolchain-resource-dirpairing, and dynamically probing/usr/lib/llvm-*/lib/libclang.so*on Linux. Unify compiler-option resolution acrossYamlConfig,FfiGenerator, andmacro_parser.dart, embed Clang diagnostics inHeaderParserException.message, and add Clang 22/23ElaboratedTyperegression tests. - Decouple test-only
hook/build.dartfrompkgs/ffigenCLI/tests/pub.dev and harden compiler/Swift hooks: Excludehook/inpkgs/ffigen/.pubignoreand movenative_test/cpp_testassets into a dedicated test helper package so pure-Dart CLI and unit tests never trigger native compilation. Verify compiler identity via--version(avoidingswiftlysymlink hijacks) with full command/stdout/stderr on failure, fixbuildSwift's iOS Simulator triple and tracked-header overwrites, and print offending file paths in rebuild errors.
P1: Check Mode, Log Hygiene, Platform Guards & Generated-Code Correctness
- Add first-class dry-run / up-to-date verification to
FfiGeneratorand honor--set-exit-if-changed: Add a built-in in-memory or check mode (FfiGenerator.check()orgenerate(dryRun: true)) and update all exampletool/ffigen.dartentrypoints (includingcode_assets/example/host_name/tool/ffigen.dart) to honor--set-exit-if-changed. Decouple_libraryIdFromConfigHashfrom temporary filenames, exposeheaderPathon publicOutput, and format in memory using the logical target directory'spubspec.yamlandanalysis_options.yamlcontext. - Eliminate log noise and align diagnostics with severity,
includeSet, and active API surface: Restrict cursor, inline-function, and enum warnings strictly toincludeSet-matched or transitively referenced declarations, deduplicate identical cursor warnings, and downgrade non-fatal enum notices fromSEVEREtoWARNING/INFO. Emit DartFfiGeneratorproperty hints instead of YAML keys (such assilence-enum-warning: true) when invoked via the Dart API. - Fail fast on non-macOS Objective-C invocation and guard against host system-header leakage: Fail fast with an actionable platform error when
language: objc/ObjectiveC(...)runs on non-macOS hosts without macOS SDK headers instead of crashing inxcrunor exiting79silently. Add diagnostics or filtering when bindings pull in host-specific system-header types (such as<pthread.h>) that diverge between Linux and macOS. - Fix generated-code correctness, analysis cleanliness, and pure-Objective-C dylib loading: Stop emitting unused
_class_<Type>fields on instance-only Objective-C categories (or includeunused_elementinignore_for_file), fix the unused$keepIsolateAliveparameter bug and naming inconsistency in generatedaddToBuilder*methods, and emit auto-generated header banners with FFIgen version metadata in.mfiles. Ensure pure-Objective-C@ffi.DefaultAssetlibraries trigger dylib loading automatically before class lookups (or surface a clear diagnostic forFailedToLoadClassException).
P2: Public API Ergonomics, Monorepo Regeneration, Test Isolation & Verified Docs
- Eliminate symbol collisions and close remaining
VisitorandScopeergonomics gaps: Complete#2770to retire legacyconfig_types.Declarationwith zerodart:core(Symbol) or internal AST collisions, and land#2850so struct fields do not collide with top-level symbols. AddParam.isUnnamed, synchronize property setter symbols onObjCMethod.name = ...with updated tests, and document or alignnode.isIncluded = falsechild-traversal semantics with JNIgen. - Unify monorepo binding regeneration, consolidate ObjC version constants, and rewrite
pkgs/ffigen/test/README.md: Provide a single documented regeneration entrypoint or manifest covering all 8 monorepo scripts (eliminating or documenting the cross-package write toobjc_built_in_types.dart) and unifyobjcMajorVersion/objcMinorVersioninto one source of truth. Rewritepkgs/ffigen/test/README.mdto remove deletedregen.dart/setup.dartreferences and document unit tests,UPDATE=truegolden runs, two-step C++/ObjC glue rebuilds, and@TestOn('mac-os')expectations. - Fix
pkgs/ffigentest isolation, CWD independence, and cross-platform example builds: Redirect all test-generated bindings (includingformat: falsetests) intoDirectory.systemTempwithaddTearDowncleanup and remove concurrentdart pub getcalls fromexpectNoAnalysisErrors. Resolve script paths viaPlatform.script/Isolate.resolvePackageUriinstead ofDirectory.current, and add Windows__declspec(dllexport)exports inpkgs/ffigen/example/add. - Improve Dart Config / Objective-C documentation, generated API discoverability, and CI doc/example verification: Make
FfiGenerator(withCBuilder.library+package:<pkg>/...defaultAsset) the primary README quick-start, consolidate v20-to-v23 and ObjC docs (including.blockingvoid-only semantics,dart tool/ffigen.dartbuild-hook ordering, andFunc.exposeSymbolAddressexamples plus@Nativeruntime tests), and emit a compact summary of renamed ObjC selectors. Gateffigen.ymlCI ondart doc --validate-links, doc snippet analysis, anddart pub get+dart analyzeacrosspkgs/ffigen/example/*.
- Dominant language
- Dart
- Stars
- 280
- Forks
- 166
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dart-lang/native
-
lang-objective_c needs-triage package:objective_c
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 2 days
-
Proposal: targetIOSVersion may need to be updated to 15 for Flutter 3.47+Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dart-lang/native#3594 · 1 comment ·
Maintainers usually reply within 2 days
-
package:ffigen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dart-lang/native#1564 · 2 comments ·
Maintainers usually reply within 2 days
-
[jnigen] Gemini's friction logPossibly taken @liamappelbe claimed this today. Openlang-java needs-triage package:jni package:jni_flutter package:jnigen
dart-lang/native#3836 · 1 assignee ·
Maintainers usually reply within 2 days
-
[jni] Reference leaks in JNIPossibly taken @liamappelbe claimed this 7 days ago. Openlang-java package:jni package:jni_flutter package:jnigen
dart-lang/native#3822 · 1 assignee ·
Maintainers usually reply within 2 days
All issues in dart-lang/native
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
nucleus-ffm/foss_warn#337 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100