[Bug]: Fatal Crash on Launch: SwiftUICore
Library Not Loaded When Using Capacitor 6 with Xcode 16 on iOS 17 and Below
#7667
Labels
Capacitor Version
Latest Dependencies:
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/ios: 6.1.2
Other API Details
Platforms Affected
Current Behavior
In a moderately intricate SwiftUI application using Capacitor version 6 with Xcode version 16, the app crashes on launch when deployed to devices running iOS 17 and below. The crash occurs due to the application attempting to load the
SwiftUICore
library, which is only available starting from iOS 18. Specifically, certain SwiftUI components, such asUIViewRepresentable
, trigger this crash by relying onSwiftUICore
. This behavior is demonstrated in the provided minimal reproducible repository, where the use ofUIViewRepresentable
leads to the fatal crash immediately upon launch. Other SPM packages likeexyte/SVGView
also cause this crash.Note:
SwiftUICore
is a new framework introduced by Apple in iOS 18 and was not present in earlier iOS versions.Expected Behavior
Xcode 16 should recognize that the
SwiftUICore
library is only available starting from iOS 18 and handle applications targeting iOS 17 and below appropriately. The app should not crash on launch due to the absence ofSwiftUICore
, and instead, the build process should either provide fallback functionality or omit the dependency as needed.While this issue might point to a bug within Xcode 16, it appears to be specifically triggered when using Capacitor 6. I have not been able to reproduce this bug in fresh Swift projects that do not involve Capacitor. The issue only arises when Capacitor is involved, indicating that Capacitor may be influencing or exacerbating the problem in some way.
Project Reproduction
https://github.com/Jaxter2017/swiftui_xcode16_bug
Additional Information
To temporarily mitigate this issue, you can adjust the build settings of your project to weakly link the
SwiftUICore
library. This allows the app to run without a strict connection to the library, preventing the crash on iOS versions whereSwiftUICore
is unavailable.Add
-weak_framework SwiftUICore
to the Other Linker Flags (OTHER_LDFLAGS) section of the Build Settings tab of your app target.The text was updated successfully, but these errors were encountered: