Does the compiler remove "Preview" types from the shipped application?

Does the compiler remove "Preview" types from the shipped application?

Thanks.
Yes. Any types unused by your actual application code are removed by the compiler, which includes PreviewProvider types. You can validate this by running nm on your Release binary and grep'ing for your preview provider type, which you should see is not included in any of the known symbols in the binary.

You can also guarantee that your shipping code doesn't accidentally reference your preview provider types by either:
  1. Putting them in a file that is included in your "Development Assets" (a project setting in the "General" tab that lets you specify paths to files/folders omitted from the archive build)

  2. Wrapping them in #if DEBUG compiler directives

However, both of those should be unnecessary as the compiler will dead code strip away those unused types for release.

Putting them in a file that is included in your "Development Assets"

Don't they have to be in the same file that you're previewing??
Does the compiler remove "Preview" types from the shipped application?
 
 
Q