Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell Asset Catalog (.xcassets) to use the Same Image for Multiple Image Wells?

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 the same image in the project.

One of our projects is correctly set to use the same images for both of these image well sets. However, this was setup more so by accident.

Besides editing the Contents.json file directly (which is a last-resort 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 image 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

3) Dragging and dropping the image with option (alt) pressed... creates a new copy of the image

like image 298
JRG-Developer Avatar asked Sep 28 '13 00:09

JRG-Developer


1 Answers

You can right click on the .xcassets file and choose 'Show in Finder'. Go to the 'Image.launchimage' folder and open the Contents.json file in a text editor. Here you can see that unassigned slots don't contain an "filename". You can add this manually. For example change the following:

{     "orientation" : "landscape",     "idiom" : "ipad",     "extent" : "full-screen",     "minimum-system-version" : "7.0",     "scale" : "2x" } 

Into:

{     "orientation" : "landscape",     "idiom" : "ipad",     "extent" : "full-screen",     "minimum-system-version" : "7.0",     "filename" : "Default-Landscape@2x~ipad.png",     "scale" : "2x" } 

Now safe the file, and voila!

like image 113
Erwin Zwart Avatar answered Sep 29 '22 11:09

Erwin Zwart