Skip to content

Flutter: Failed to lookup symbol 'mmkvInitialize': dlsym(RTLD_DEFAULT, mmkvInitialize): symbol not found #1676

Description

@blackstorm

The language of MMKV

Dart / FFI (via mmkv_ios Flutter plugin, wrapping the native MMKV library written in Objective‑C++ / C++)

The version of MMKV

v2.4.1 (latest, released 2026-07-30) — runtime regression; v2.4.0 works when installed via CocoaPods.

The platform of MMKV

iOS (Xcode 26.0, iPhoneOS 26.0 SDK, arm64, physical device only; simulator builds work without this issue)

The installation of MMKV

  • Swift Package Manager (SPM) – integrated via the Flutter plugin mmkv / mmkv_ios (pubspec dependency).
  • The native library is declared in the Xcode project through SPM (Package.resolved).
  • Not using CocoaPods for this setup. For comparison, v2.4.0 via CocoaPods works on both simulators and devices.

What's the issue?

On physical iOS devices, the app crashes immediately after launch when MMKV.initialize() is called. The Dart FFI layer fails to look up the symbol mmkvInitialize:

ArgumentError: Invalid argument(s): Failed to lookup symbol 'mmkvInitialize': dlsym(RTLD_DEFAULT, mmkvInitialize): symbol not found

The root cause: the native MMKV framework is not bundled into the final .app for device builds. Inspecting the app package reveals that MMKV.framework is missing from the Frameworks folder.

  • The build succeeds with no compile errors.
  • The crash occurs only on physical devices; simulator builds run fine because the library might be linked differently or the simulator uses a different path.
  • The same project built with v2.4.0 via CocoaPods includes the framework correctly on both simulators and devices.

What's the log of MMKV when that happened?

No MMKV log is produced because the library is never loaded.

Full error stack trace (sanitized):

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ArgumentError: Invalid argument(s): Failed to lookup symbol 'mmkvInitialize': dlsym(RTLD_DEFAULT, mmkvInitialize): symbol not found
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33)
#1      MMKVPlatformIOS._mmkvInitialize (package:mmkv_ios/mmkv_ios.dart:48)
#2      MMKVPlatformIOS.initialize (package:mmkv_ios/mmkv_ios.dart:54)
#3      MMKV.initialize (package:mmkv/mmkv.dart:228)
#4      warmUpPlatformAndStorage (package:your_app/app/run_app.dart:106)
#5      bootstrapAndRun (package:your_app/app/run_app.dart:45)
...

The main thread (thread 0) crashes with this exception; other threads (raster, I/O, workers) are idle.

Environment details (additional context)

  • Xcode: 26.0 (Build 17A400)
  • iOS SDK: 26.0 (iphoneos26.0)
  • Flutter: version 3.12.2 (using mmkv plugin, latest)
  • Deployment target: iOS 15+ (tested on iOS 26.6 and 18.7.8 physical devices)

Version comparison

The following observations have been made across different installation methods and MMKV versions:

Installation Method MMKV Version Result
CocoaPods 2.4.0 Builds successfully, works correctly on both simulator and physical devices.
SPM 2.4.1 Builds without compile errors. However, it crashes at runtime on physical devices due to the missing symbol mmkvInitialize. On simulators, the same SPM setup works fine.

Additional observations

  • The missing framework on device builds indicates that the SPM package definition for v2.4.1 does not correctly handle embedding for physical architectures (arm64).
  • Simulator builds may use a different linking strategy (e.g., dynamic linking from the build directory), which hides the problem.
  • This is a regression from v2.4.0, where CocoaPods correctly embedded the library for all targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions