Skip to content

[BUG] default.metallib bundle missing when using Tuist (SwiftPM bundle not emitted) #349

@Skyline-23

Description

@Skyline-23

Describe the bug
When mlx-swift is integrated via Tuist, runtime crashes on iOS device with:
Failed to load the default metallib (library not found).
MLX searches for mlx-swift_Cmlx.bundle/default.metallib, but Tuist doesn't emit the SwiftPM resource bundle for external dependencies (because the metallib is a build artifact, not declared as a resource). As a result the bundle is missing at runtime.

To Reproduce

Include code snippet

// Minimal usage that triggers MLX init
import MLX
import Cmlx
// e.g. initialize MLX or any model load

Steps:

  1. Create a Tuist project that depends on mlx-swift (Cmlx + MLX).
  2. Build & run on a real iOS device (not simulator).
  3. App/test host crashes with “Failed to load the default metallib (library not found)”.

Workaround (build script):

# Copy default.metallib into SwiftPM bundle path expected by MLX
BUNDLE_DIR="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/mlx-swift_Cmlx.bundle"
mkdir -p "${BUNDLE_DIR}"
cp -f "${BUILT_PRODUCTS_DIR}/Cmlx.framework/default.metallib" "${BUNDLE_DIR}/default.metallib"

Related MLX source (load paths):

Expected behavior
MLX should find its metallib when integrated via Tuist (or any build system that doesn’t auto-generate SwiftPM resource bundles for external deps). Ideally default.metallib should be declared as a SwiftPM resource or shipped in a stable bundle path.

Desktop (please complete the following information):

  • OS Version: macOS 26.2 (host), iOS 26.2.1 (device)
  • Device: iPhone Air (iOS 26.2.1)
  • Version: mlx-swift (main), Tuist 4.133.4, Xcode 26.2

Additional context
Tuist does not auto-emit SwiftPM resource bundles for external dependencies when the resource is a build artifact. The workaround above copies default.metallib into mlx-swift_Cmlx.bundle and fixes the crash.

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