Skip to content

iOS simulator native asset hook returns the same fat dylib for arm64 and x86_64 Flutter builds #45

@alealv

Description

@alealv

Summary

When sqlite_vector is used from a Flutter app on iOS simulator, the native-asset build hook returns the same fat simulator dylib for both arm64 and x86_64 targets. Flutter then tries to package those outputs together and fails during the simulator build.

Package Version

  • sqlite_vector 0.9.85

Environment

  • Flutter 3.41.2
  • Xcode 26.1.1
  • iOS simulator build (just build ios --simulator --no-codesign in our case, but this is a normal Flutter iOS simulator build)

Failure

Flutter fails during iOS simulator packaging with an error like:

Target install_code_assets failed: Error: Failed to create universal binary:
fatal error: .../usr/bin/lipo: .../vector_ios-sim.dylib and .../vector_ios-sim.dylib have the same architectures (x86_64) and can't be in the same fat output file

Root Cause

The current hook returns native_libraries/ios-sim/vector_ios-sim.dylib for every iOS simulator build, regardless of target architecture:

  • simulator arm64 build -> ios-sim/vector_ios-sim.dylib
  • simulator x86_64 build -> ios-sim/vector_ios-sim.dylib

That file is already a fat dylib containing both architectures, so Flutter ends up trying to combine duplicate inputs.

We confirmed this by inspecting the hook outputs for both simulator targets: both originally pointed at the same vector_ios-sim.dylib.

What Fixed It Locally

We patched the build hook so that for iOS simulator builds it thins the fat dylib per target architecture and emits an arch-specific output file:

  • arm64 -> vector_ios_sim_arm64.dylib
  • x86_64 -> vector_ios_sim_x86_64.dylib

After that, the Flutter iOS simulator build succeeded.

Suggested Fix

In hook/build.dart, for OS.iOS + simulator targets, emit an architecture-specific dylib instead of returning the same fat simulator binary for every target.

If helpful, I can open a PR with the hook change we tested locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions