In my SwiftUI app, I have put some sample model objects in Xcode's "Preview Content" folder. I only access them in my SwiftUI PreviewProvider
s. My understanding is that the code/assets in this folder are only used for previewing in the Canvas. My previews work properly. I'm using Xcode 11.6 (11E708).
However, when I go to Archive my app, it fails because it cannot find these sample model objects. I was under the impression that PreviewProvider
code is not build into the final binary as of Xcode 11. See this question, along with the item from the Xcode 11 release notes that says,
Resolved Issues
The
#if
/#endif
compiler conditionals surrounding PreviewProvider types have been removed from SwiftUI templates. PreviewProviders aren’t properly removed from built products when archived. (51539802)
(Curiously, I am able to compile with the Release configuration. It's just Archive that fails.)
As a workaround, I can put the #if DEBUG
/#endif
wrappers around my PreviewProvider
but the above quote from the release notes indicates that shouldn't be necessary.
Do I misunderstand how the "Preview Content" folder works?