Skip to content

When using SPM, missing library error "SwiftUICore" on iOS below 18 is not documented #574

Description

@CrisBerriosL

URL
The URL at which the content is missing or inaccurate
https://capacitorjs.com/docs/ios/spm

What is missing or inaccurate about the content on this page?

Summary

This page documents migrating to / using Swift Package Manager on iOS, but it does not warn about a crash-on-launch that this setup causes on iOS 15, 16, and 17 — the very range Capacitor 8 still supports (iOS deployment target 15). Apps build and pass review, launch fine on iOS 18+, and then hard-crash at launch for every user below iOS 18.

Symptom

The app terminates immediately at launch (before the web view loads) on iOS 15–17. It works normally on iOS 18+. Crash report shows a dyld failure:

Termination Reason: DYLD, Library missing
Library not loaded: /System/Library/Frameworks/SwiftUICore.framework/SwiftUICore
Referenced from: .../App.app/App
Reason: tried: '.../SwiftUICore.framework/SwiftUICore' (no such file, not in dyld cache)

Exception Type: EXC_CRASH (SIGABRT), terminated at launch.

Root cause

SwiftUICore is a private framework Apple split out of SwiftUI; it only exists as a standalone framework on iOS 18+. Under SPM, Capacitor plugins are statically linked into the main App binary, so a plugin that references SwiftUI pulls a strong link to SwiftUICore into App itself. Xcode (16 and later, including 26.x) links it strongly even though the minimum deployment target is iOS 15, with no warning — so the binary can't load on any device below iOS 18.

Fix (should be documented here)

In XCode, select the App in Targets, and go to Build Settings. In the "Basic/Customized/All" filter select "All", and search for "Other Linker Flags".
Add two separate entries:

  • -weak_framework
  • SwiftUICore

Weak-linking is safe: if SwiftUICore isn't linked it's a no-op; if it is, it lets the app launch on iOS 15–17 (the symbols aren't actually called there); on iOS 18+ it behaves identically.

Suggested change

Add a "⚠️ Known issue" callout to this page with the symptom + the -weak_framework SwiftUICore workaround.

Note: this isn't only a migration issue

A new app started on Capacitor 8 + SPM with deployment target 15 hits the same crash, so the same warning belongs on the iOS getting-started / new-project docs too. Longer term this could be automated (e.g. adding the flag to the @capacitor/ios project template, or a cap doctor check for a deployment-target/SwiftUICore mismatch) — happy to open a separate issue for that if useful.

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