Previews doesn't work in package target's subdirectory

I'm trying to preview a view from a swift package which is located in one of the target's directory subdirectories:

Code Block
.
├── Package.swift
├── README.md
└── Sources
└── SatelitUI
└── Views
└── MenuBar.swift


When I'm previewing a view from the MenuBar.swift file I'm getting following error:

Code Block
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.


Which is unexpected because the file should be a part of the SatelitUI target. The thing is it works just fine if I move it into the root target's directory (SatelitUI).

Accepted Reply

Thanks, we are tracking this as a bug and are investigating. As you already noticed, the only workaround at this time is moving the file you would like to preview into the root of the target's directory.

Replies

Thanks, we are tracking this as a bug and are investigating. As you already noticed, the only workaround at this time is moving the file you would like to preview into the root of the target's directory.
I'm having the same issue
This seems to be resolved in Xcode 12 beta 3.
Unfortunately I am still experiencing this issue in Xcode 12 beta 3
I can also still reproduce this issue in Xcode 12 beta 3.

Any update? Xcode 14.2, I still have this issue

I think this might be related to Xcode's installation path, and how iCloud interacts with folders like Downloads. None of the suggestions I've seen around resolved this but it's now consistently working for me after I moved Xcode into Applications. It was in Downloads and I never realized since I keep it pinned.

Still having this issue. It's 3 years later and it seems like this still isn't fixed?