An open API service indexing awesome lists of open source software.

https://github.com/ctreffs/swiftui-previews-module-resources-fix

Swiftui Xcode previews module resources fix
https://github.com/ctreffs/swiftui-previews-module-resources-fix

resources spm swift swift-package-manager swiftui xcode xcpreviews

Last synced: about 1 year ago
JSON representation

Swiftui Xcode previews module resources fix

Awesome Lists containing this project

README

          

# Swiftui Xcode previews module resources fix

A demo of a fix for a XCPreviewAgent crash due to resource dependencies accross modules.

It specificially fixes crashes like this:

```swift
unable to find bundle named _

----------------------------------------

CrashReportError: `fatalError` in resource_bundle_accessor.swift

XCPreviewAgent crashed due to fatalError in resource_bundle_accessor.swift at line 27.

unable to find bundle named _

Process: XCPreviewAgent

```

### See the crash

To see the crash in action: `git switch crash`.
The `crash` branch demonstrates the implementation as it should work with XCPreviews.
Just try to open `ModulUI`'s preview.

### Resouces

- https://forums.swift.org/t/xcode-previews-swiftpm-resources-xcpreviewagent-crashed/51680/8
- https://stackoverflow.com/questions/64540082/xcode-12-swiftui-preview-doesnt-work-on-swift-package-when-have-another-swift/65789298#65789298
- https://feedbackassistant.apple.com/feedback/10102512