#16130·tauri

[bug] [ios] Release build fails to link on Xcode 27: SwiftPM's default build system gives non-`public` `@_cdecl` functions local visibility

Author: wx-shenCreated Sep 24, 2026Updated Sep 24, 2026
Labelstype: bugstatus: needs triageplatform: iOS

Describe the bug

With Xcode 27 (Swift 6.4), tauri ios build in release fails at the cargo build link step. Every undefined symbol is a function defined in Swift with @_cdecl: _register_plugin, _log_stdout, _retain_object, _init_plugin_opener and others (full list under Stack trace). Debug builds link fine.

The Swift static libraries still contain these symbols, but with local visibility (t instead of T in nm), so the Rust linker cannot resolve them. SwiftPM 6.4 now uses Swift Build as its default build system, and in release configuration Swift Build gives non-public @_cdecl functions local visibility. All of Tauri's @_cdecl entry points are declared without public.

This is related to the general Xcode 27 issue #16121, but it has a separate, narrowly reproducible cause.

Reproduction

In a Tauri app (tauri 2.11.5 + tauri-plugin-opener 2.5.5, Xcode 27.0):

cargo tauri ios build

It fails with the linker error shown under Stack trace. cargo tauri ios build --debug links fine.

Minimal reproduction without Tauri. The same behaviour shows up with a two-function Swift package.

Package.swift:

swift
// swift-tools-version:5.9
import PackageDescription
let package = Package(
    name: "Repro",
    platforms: [.iOS(.v15)],
    products: [.library(name: "Repro", type: .static, targets: ["Repro"])],
    targets: [.target(name: "Repro", path: "Sources/Repro")]
)

Sources/Repro/Repro.swift:

swift
@_cdecl("internal_export")
func internalExport() -> Int32 { 1 }

@_cdecl("public_export")
public func publicExport() -> Int32 { 2 }

Build it with the same arguments swift-rs passes, then inspect the symbols:

bash
swift build --sdk "$(xcrun --sdk iphoneos --show-sdk-path)" -c release \
  --triple arm64-apple-ios15.0 -Xcc --target=arm64-apple-ios15.0
nm <build-path>/…/libRepro.a | grep _export
configuration / build system _internal_export _public_export
-c debug (default build system) T T
-c release (default = Swift Build) t T
-c release --build-system native T T

Compiling the same file directly with swiftc -O -wmo keeps _internal_export as T. So the problem is in the SwiftPM / Swift Build release pipeline, not in the Swift optimizer in general.

Expected behavior

cargo tauri ios build in release links, as it does in debug and as it did with previous Xcode versions. The @_cdecl entry points that Rust links against should be global symbols regardless of build system and configuration.

Full tauri info output

[✔] Environment
    - OS: Mac OS 26.6.2 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ Xcode: 27.0
    ✔ rustc: 1.98.1 (48a229cea 2026-09-01)
    ✔ cargo: 1.98.1 (797e8a9bc 2026-08-05)
    ✔ rustup: 1.29.1 (d95a37b6a 2026-08-13)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (overridden by '<project>/rust-toolchain.toml')
    - node: 24.17.0
    - pnpm: 11.10.0
    - npm: 11.13.0
    - bun: 1.3.14

thread '<unnamed>' panicked at crates/tauri-cli/src/info/packages_nodejs.rs:181:76:
called `Result::unwrap()` on an `Err` value: Error("unexpected character '[' while parsing major version number")

tauri info panics while collecting the Node.js package versions, which is a separate problem. The relevant versions, taken from Cargo.lock and node_modules, are:

tauri 2.11.5 · tauri-build 2.6.3 · tauri-runtime-wry 2.11.4 · wry 0.55.1 · tao 0.35.3
tauri-plugin-opener 2.5.5 · swift-rs 1.0.8
@tauri-apps/cli 2.11.4 · @tauri-apps/api 2.11.1
Swift 6.4 / Swift Package Manager 6.4.0 (Xcode 27.0, 27A266a), iOS SDK 27.0, target aarch64-apple-ios, deployment target 15.0

Stack trace

error: linking with `cc` failed: exit status: 1
  = note: ld: warning: ignoring duplicate libraries: '-lclang_rt.ios'
          Undefined symbols for architecture arm64:
            "_init_plugin_opener", referenced from: ...
            "_log_stdout", referenced from: ...
            "_on_webview_created", referenced from: ...
            "_register_plugin", referenced from: ...
            "_release_object", referenced from: ...
            "_retain_object", referenced from: ...
            "_run_plugin_command", referenced from: ...
            "_string_from_bytes", referenced from: ...
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile `tauri-app` (lib) due to 1 previous error
failed to compile iOS app: Failed to run `cargo build`: command ["cargo", "build", "--package", "tauri-app", …, "--target", "aarch64-apple-ios", …, "--lib", "--release"] exited with code 101

nm on the Swift object built by swift-rs in this release build:

000000000000b614 t _log_stdout
000000000000b744 t _register_plugin

In the debug build the same symbols are T.

Additional context

Affected declarations. Every one is @_cdecl("…") func … without public:

  • crates/tauri/mobile/ios-api/Sources/Tauri/Tauri.swift: log_stdout, register_plugin, on_webview_created, run_plugin_command. These are unchanged in 2.11.6 and on dev.
  • swift-rs src-swift/lib.swift: retain_object, release_object, string_from_bytes.
  • Every plugin's iOS entry point, for example tauri-plugin-opener ios/Sources/OpenerPlugin.swift: init_plugin_opener. The plugin template has the same shape.

Suggested fix. Mark every @_cdecl entry point that Rust links against as public, in ios-api, in swift-rs, and in the plugin template and existing plugins. This works under both build systems. Passing --build-system native from swift-rs would also work for now, but SwiftPM 6.4 already warns that this flag is deprecated. It may also be worth asking upstream Swift Build whether @_cdecl should imply external visibility; I haven't filed anything there.

Workaround. swift-rs picks the Swift configuration from cargo's DEBUG env var, which follows whether debuginfo is enabled, not opt-level. So a dev profile that keeps debuginfo but optimizes Rust builds Swift in debug configuration and links:

bash
CARGO_PROFILE_DEV_OPT_LEVEL=3 CARGO_PROFILE_DEV_DEBUG=line-tables-only \
CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false CARGO_PROFILE_DEV_OVERFLOW_CHECKS=false \
  cargo tauri ios build --debug

Setting CARGO_PROFILE_DEV_DEBUG=0 turns DEBUG off, so Swift is built in release again and the link fails.