Xcode SwiftUI preview canvas error for Swift package

Hi!
I created this github sample project to describe an issue with the Xcode 11 SwiftUI preview canvas pane (⌥ + ⌘ + return) in combination with the Swift package.

It seems that SwiftUI preview is working only for source files in Sources/[target] directory
(Package -> Sources -> TargetName) ,
but not in subfolders (Package -> Sources -> TargetName -> Subfolder ) .

File \FeaturePackage\Sources\FeaturePackage\SampleButton.swift
- preview is working

File \FeaturePackage\Sources\FeaturePackage\Subfolder\SampleButton.swift

  • Error:
NoBuildableEntriesError: active scheme does not build this file

Select a scheme that builds a target which contains the current file, or add this file to a target that is built by the current scheme.

I know this is the forum about Swift language, not Xcode. But the described issue started to appear when we switched from framework to Swift Package.

1 Like

Did you found a solution for this ?
I have the same issue for any location not only within subfolders.

No, I switched back to cocoa frameworks.

@pykaso So the preview worked for you?
With Xcode 11.3.1 it doesn't matter where my file is located the Preview errors out. If I move it back to the iOS Project, than it's fine.