Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of "Preview Assets" assets catalog in Xcode 11 beta?

What is the use of "Preview Assets" assets catalog in Xcode 11 beta?

XCode 11 Beta - Screenshot

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?

like image 495
Ashish Kakkad Avatar asked Jun 09 '19 04:06

Ashish Kakkad


People also ask

What is Xcode previews used for?

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.

How do I create a preview in SwiftUI?

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.

What's new in iOS 11 with asset catalogs?

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.

What is the “preview assets” catalog?

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.

What are development assets in Xcode?

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.

Is it possible to add color to an asset catalog?

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.


2 Answers

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

like image 195
Argas Avatar answered Oct 19 '22 07:10

Argas


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

like image 2
Sophy Swicz Avatar answered Oct 19 '22 06:10

Sophy Swicz