Unable to view SwiftUI Previews when developing a Package

Originator:david
Number:rdar://FB7708911 Date Originated:5/20/2020
Status:Open Resolved:
Product:Xcode Product Version:iOS 13.4.1
Classification: Reproducible:Yes
 
When I am working on a single view iOS app, I am able to get instant feedback on the preview screen for the view I am working on. I created a Swift Package to try and work on a SwiftUI view that I could easily ship in a package to reuse in other applications, and I did not get the behavior I expected. Here is the way I would expect this to work:

1. Create a new Swift Package from the Xcode file --> new menu.
2. Add the iOS platform to Package.swift.
3. Create a new SwiftUI view in the package with public access control to make it usable.
4. Develop the view with immediate feedback in an acceptable simulator in the IDE.

Safe to say, the above steps do not work. The error I get at this stage is that there is "no workspace arena", which makes sense given the dynamic nature of SwiftUI previews, but it would be helpful to have a silent simulator instance available to link this for the sake of this style of development.

Please list the steps you took to reproduce the issue:
It took some extra doing to get previews to show up, and the situation was so contrived that I wonder if it would be worth it to reproduce. I worked extensively with Harlan Haskins on this to try and get it to work, and he was very generous and gracious helping out. Here is what we did to ultimately get them to work, starting from the end of step 4 in the previously mentioned dialog:

5. Mark the library in Package.swift with `type: .dynamic`
6. Create a new iOS project as a single view app.
7. Drag the package directory into the project
8. Dynamically link the library in the container project as an embedded dynamic framework and sign it.

After doing this, I could make changes to the view in that project window, and I could preview them, but each modifier added to `var body` required a press of the "Resume" button.
I expected to see a live preview of my SwiftUI view while developing it in the Package.swift folder.

I was given an error that made this type of work a non-starter.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!