What is the use of "Preview Assets" assets catalog in Xcode 11 beta?
I have just created new project with SwiftUI. I have checked release notes of Xcode 11 beta but there is no information about this assets catalog.
What is the use of it?
Now Xcode Previews is a new feature of Xcode that allows you to - that institute - minimize the amount of time you spend building and running and configuring your views to verify the changes that you are making. And to - and lets you focus on the things that you love doing best, which is building great apps.
There are two shortcuts that you should remember. Both of them will make your life easier during the development cycle of your SwiftUI views. Cmd + Option + Enter shows or hides previews. Cmd + Option + P runs the previews.
As you know, you are able to use Xcode Asset Catalogs to manage your images and other file-based resources since iOS 7. But from iOS 11 (with Xcode 9), Asset catalogs support named colors that can be used in source files and Interface Builder.
New Xcode projects contain a “Preview Assets” asset catalog by default. As Apple expects us to use SwiftUI previews more and more, they want to make it easy for us to provide sample data to use within those previews.
Development Assets in Xcode allow you to provide test data to use during development. You can find the Development Assets configuration within your target configuration at the very bottom of the general tab. It’s a list presentation of any files marked as being used for development only.
But from iOS 11 (with Xcode 9), Asset catalogs support named colors that can be used in source files and Interface Builder. You can create a color that is device-specific or the same on all devices.
Now, when you layout your views you can preview it in Canvas (the window from the right side of the code editor). Obviously, some images and other data for your app you can get only in runtime, from your API for example. So all stubs can be placed into Preview Content folder, in particular in Preview Assets
For more info about it:
The idea of it, it's to avoid releasing the files inside it into production. In that way you decrease the size of the build since they will be removed in the archive fase.
https://www.avanderlee.com/xcode/development-assets-preview-catalog/
Like @peterSchorn mentioned in the comment before mine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With