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

Include dir was invalid. {} doesn't exist or isn't a directo

Error message

Include dir was invalid. {} doesn't exist or isn't a directory

What it means

After validating the iOS SDK root in the Xcode script helper, tauri-cli checks that `<sdk_root>/usr/include` exists, because that include directory is exported as OBJC_INCLUDE_PATH_<triple> for the Rust build. If it is missing, the SDK is considered incomplete/corrupt and the build stops.

Source

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

        .iter()
        .map(|conf| &conf.0)
        .collect::<Vec<_>>(),
    )?;
  }

  let env = env()
    .context("failed to load iOS environment")?
    .explicit_env_vars(cli_options.vars);

  if !options.sdk_root.is_dir() {
    crate::error::bail!(
      "SDK root provided by Xcode was invalid. {} doesn't exist or isn't a directory",
      options.sdk_root.display(),
    );
  }
  let include_dir = options.sdk_root.join("usr/include");
  if !include_dir.is_dir() {
    crate::error::bail!(
      "Include dir was invalid. {} doesn't exist or isn't a directory",
      include_dir.display()
    );
  }

  // Host flags that are used by build scripts
  let macos_isysroot = {
    let macos_sdk_root = options
      .sdk_root
      .join("../../../../MacOSX.platform/Developer/SDKs/MacOSX.sdk");
    if !macos_sdk_root.is_dir() {
      crate::error::bail!("Invalid SDK root {}", macos_sdk_root.display());
    }
    format!("-isysroot {}", macos_sdk_root.display())
  };

  let mut host_env = HashMap::<&str, &OsStr>::new();

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Verify manually: `test -d "$(xcrun --sdk iphoneos --show-sdk-path)/usr/include" && echo ok`.
  2. Reinstall the iOS platform: `xcodebuild -downloadPlatform iOS` (delete the partial platform first if needed).
  3. If overriding SDK root, point it at the exact `.sdk` directory reported by `xcrun --sdk iphoneos --show-sdk-path`.
  4. As a last resort reinstall Xcode.

Example fix

# before
# --sdk-root /Applications/Xcode.app/.../Platforms/iPhoneOS.platform
# error: Include dir was invalid. .../usr/include doesn't exist

# after
# --sdk-root /Applications/Xcode.app/.../Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk
# or simply let Xcode pass SDKROOT untouched
Defensive patterns

Strategy: validation

Validate before calling

SDK=$(xcrun --sdk iphoneos --show-sdk-path)
test -d "$SDK/usr/include" && echo "include ok" || xcodebuild -downloadPlatform iOS

Prevention

When it happens

Trigger: Building the iOS app in Xcode where the SDK root directory exists but its `usr/include` folder does not — typically a partially downloaded/corrupted iOS platform, or an SDK root argument that points at the platform folder instead of the inner `.sdk` folder (e.g. .../iPhoneOS.platform instead of .../iPhoneOS.sdk).

Common situations: Interrupted `xcodebuild -downloadPlatform iOS` leaving a truncated SDK; pointing `--sdk-root` at the wrong folder level; macOS upgraded and the SDK structure moved; unusual Xcode installs (beta vs stable mixing).

Related errors


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