Use asset catalogs to simplify management of images that are used by your app as part of its user interface.
An asset catalog can include:
- Image sets: Used for most types of images, an image set contains all the versions, or representations, of an image that are necessary to support various devices and scale factors.
- App icons: App icon sets contain all the representations of the icon that iOS apps must provide to be displayed on a device’s Home screen and in the App Store.
- Launch images: Launch image sets contain all the representations of the static launch image that iOS apps must provide to be temporarily displayed when the app is launched.
- OS X icons: OS X icon sets contain all the representations of an icon that OS X apps must provide.
View and customize the contents of asset catalogs using three main areas:
- Set list: See a list of all image sets, app icon sets, and image launch sets in the selected asset catalog.
- Set viewer: View the individual image representations for the selected set.
- Set Attributes inspector: Depending on what’s selected in the Set viewer, you can view and edit image attributes. Editable attributes include a set’s name, image types, template setting, and supported devices, size classes, and iOS versions. You can view the properties of an image including name, size, color space, as well as others.
Each set in an asset catalog has a name. You can use that name to programmatically load any individual image contained in the set. To load an image, call the platform specific class method, passing in the name of the set that contains the image. The OS will load the image from the set that is most appropriate for the current scale factor. The platform method for iOS is
imageNamed:. For OS X the platform method is
Xcode 6 provides different functionality for asset catalogs depending on the deployment target for your project:
- For all projects, individual images can be loaded using set names.
- For projects with a deployment target of at least iOS 7 or OS X 10.9, Xcode compiles your asset catalogs into a runtime binary file format that reduces the download time for your app.
Each asset catalog in Xcode has a corresponding folder in the Finder, with an .xcassets extension, and subfolders for each set. Each set folder in turn contains its image representations, along with a
Contents.json file, describing each image. That file is automatically created by Xcode.
You can share asset catalogs across multiple projects in the same workspace.