Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fatal Crash on Launch: SwiftUICore Library Not Loaded When Using Capacitor 6 with Xcode 16 on iOS 17 and Below #7667

Open
1 of 3 tasks
Jaxter2017 opened this issue Sep 19, 2024 · 0 comments
Labels

Comments

@Jaxter2017
Copy link

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

- **Xcode Version:** 16
- **iOS Versions Affected:** 17 and below
- **SwiftUI Components Involved:** `UIViewRepresentable`, others requiring `SwiftUICore`
- **SwiftUICore Framework:** Introduced in iOS 18, not present in earlier iOS versions.

### API and Tooling Versions

- **npm Version:** 9.5.1
- **Node.js Version:** v18.16.0
- **CocoaPods Version:** 1.15.2 (although same bug occurs when using SPM Capacitor v6 with `npx cap add ios --packagemanager SPM`)

Platforms Affected

  • iOS
  • Android
  • Web

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 as UIViewRepresentable, trigger this crash by relying on SwiftUICore. This behavior is demonstrated in the provided minimal reproducible repository, where the use of UIViewRepresentable leads to the fatal crash immediately upon launch. Other SPM packages like exyte/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 of SwiftUICore, 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 where SwiftUICore is unavailable.

Add -weak_framework SwiftUICore to the Other Linker Flags (OTHER_LDFLAGS) section of the Build Settings tab of your app target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant