tauri-apps/tauri · error · tauri_cli::error::Error

Library not found at {}. Make sure your Cargo.toml file has

Error message

Library not found at {}. Make sure your Cargo.toml file has a [lib] block with `crate-type = ["staticlib", "cdylib", "lib"]`

What it means

After the Xcode script helper compiles the Rust library, it expects a static library at `<target/<triple>/<profile>/debug|release>/lib{lib.name}.a` (from the `[lib] name` in Cargo.toml). If that file does not exist, it tells you the Cargo.toml is missing the mobile crate-types — without `crate-type = ["staticlib", ...]` cargo never produces the .a that gets linked into the app.

Source

Thrown at crates/tauri-cli/src/mobile/ios/xcode_script.rs:281

        true,
        profile,
        &env,
        target_env,
      )
      .context("failed to compile iOS app")?;

    let out_dir = interface.app_settings().out_dir(
      &InterfaceOptions {
        debug: matches!(profile, Profile::Debug),
        target: Some(rust_triple.into()),
        ..Default::default()
      },
      dirs.tauri,
    )?;

    let lib_path = out_dir.join(format!("lib{}.a", config.app().lib_name()));
    if !lib_path.exists() {
      crate::error::bail!("Library not found at {}. Make sure your Cargo.toml file has a [lib] block with `crate-type = [\"staticlib\", \"cdylib\", \"lib\"]`", lib_path.display());
    }

    validate_lib(&lib_path)?;

    let project_dir = config.project_dir();
    let externals_lib_dir = project_dir.join(format!("Externals/{arch}/{}", profile.as_str()));
    std::fs::create_dir_all(&externals_lib_dir).fs_context(
      "failed to create externals lib directory",
      externals_lib_dir.clone(),
    )?;

    // backwards compatible lib output file name
    let uses_new_lib_output_file_name = {
      let pbxproj_path = project_dir
        .join(format!("{}.xcodeproj", config.app().name()))
        .join("project.pbxproj");
      let pbxproj_contents = read_to_string(&pbxproj_path)
        .fs_context("failed to read project.pbxproj file", pbxproj_path)?;

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Add the required crate-types in src-tauri/Cargo.toml under `[lib]`: `crate-type = ["staticlib", "cdylib", "lib"]`.
  2. Re-run `tauri ios init` after changing `[lib] name` or `package.name` so the Xcode project matches.
  3. Scroll the Xcode report navigator for the real cargo error — a failed build also leaves no .a.
  4. Check out_dir manually: `ls target/aarch64-apple-ios/debug/lib*.a` (or release) to confirm where cargo wrote it.

Example fix

# before (src-tauri/Cargo.toml)
[lib]
name = "myapp_lib"

# after
[lib]
name = "myapp_lib"
crate-type = ["staticlib", "cdylib", "lib"]
Defensive patterns

Strategy: validation

Validate before calling

# Verify the mobile static lib exists where Xcode expects it
TRIPLE=aarch64-apple-ios
test -f "src-tauri/target/$TRIPLE/debug/lib$(grep -m1 '^name' src-tauri/Cargo.toml | cut -d'"' -f2).a" \
  || cargo build --manifest-path src-tauri/Cargo.toml --target $TRIPLE

Prevention

When it happens

Trigger: The Xcode build phase runs `tauri ios xcode-script`, cargo finishes (or was skipped), and `lib<name>.a` is absent from out_dir. Direct triggers: no `[lib] crate-type` including `staticlib`/`cdylib`; `[lib] name` renamed after `tauri ios init` so the generated project looks for a different name; an earlier cargo failure swallowed by logs; CARGO_TARGET_DIR redirected.

Common situations: Hand-migrating a desktop-only Tauri app to iOS without adding the lib crate-types; renaming the crate or lib.name and not re-running `tauri ios init`; custom target directories in .cargo/config.toml.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/7d5bd5989bcca27e. Report an issue: GitHub.