Friday, 27 September 2013

How can you tell an Asset Catalog (.xcassets) to use the same image for multiple settings?

How can you tell an Asset Catalog (.xcassets) to use the same image for
multiple settings?

We have several Xcode app projects, and we're upgrading all of them to use
the latest Xcode 5 features, including Asset Catalogs (.xcassets).
All of our default (launch) images already include spacing for the status
bar, and we want to use these images for both the iOS 5,6 and iOS 7 launch
images. Further, we don't want to include multiple copies of these images.
One of our projects is correctly set to use the same image for both of
these sets. However, this was setup more so by accident.
Besides editing the Contents.json file directly (which, I suppose, is a
workaround if need be), how can we do this using the Xcode GUI editor for
Asset Catalog?
What we've already tried
1) Dragging and dropping the file to a different position... just moves
the image to the other set
2) Dragging and dropping the same file from Finder to the Asset Catalog...
creates a new copy of the image

2 comments:

  1. Did you find a solution? I'm faced with this very same problem and don't want to have two copies of the images.

    ReplyDelete
  2. For images that are definitely the same size, you can use this technique. But for ones that are different, like iOS 6 and 7 iPad launch images, you have to use separate assets:

    The trick is to right-click the asset, choose Show in Finder, and then edit the JSON file directly to have multiple assets point a the same resource. It's worked pretty well for me so far.

    ReplyDelete