30

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

JRG-Developer
  • 12,454
  • 8
  • 55
  • 81
  • Have you tried dragging and dropping from a position to another with option (ALT) pressed? – Marcelo Sep 30 '13 at 01:54
  • @MarceloFabri, I think so, but I'll give it a go again... – JRG-Developer Sep 30 '13 at 01:57
  • @MarceloFabri, Nope, just copies the image to the other set... so you wind up with multiple images (i.e. second image named "Default@2x-1.png") – JRG-Developer Sep 30 '13 at 02:04
  • another very common use case: using the same image as a launch image + background for your 'home' view – toblerpwn Oct 01 '13 at 03:26
  • Well, you can just check `iOS 6.0 and Prior` option only and the launch image will be used in all systems (5,6,7) – Alladinian Oct 04 '13 at 12:20
  • @Alladinian, if you do this, you'll actually get a compiler warning complaining about missing assets for `iOS 7`. – JRG-Developer Oct 04 '13 at 19:20
  • @JRG-Developer Strange, I thought I only got the warning for R4 only... I'll check though – Alladinian Oct 04 '13 at 19:56
  • @JRG-Developer Seems like a poor implementation of the feature, cause it appears that only R4 is required for both iOS7 and prior, which doesn't make sense... ([screenshot here](http://cl.ly/image/3s1R2D3b3a0C) - no compiler warnings) – Alladinian Oct 05 '13 at 20:02

6 Answers6

8

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!

  • Yeah, this was mentioned within the question prompt. The hope is to be able to do this entirely from the Xcode GUI editor. – JRG-Developer Oct 04 '13 at 23:35
  • 2
    This doesn't have impact on the size of the build since the build product contains all the duplications of the launch images, named correspondingly – Alexander Kostiev Feb 13 '14 at 07:26
0

I solved this by using build scripts to copy the right xcassets file in for each target. Details here

coneybeare
  • 33,113
  • 21
  • 131
  • 183
0

I think I've found the solution: Simply drag the default images that you want to be used for iOS 6 and 7 into the iOS 6 bucket. You get a warning about not having an iOS7-only image but the build works in the iOS7 simulato, an iOS7 iPhone and an iOS7 iPad.

0

I solved this by removing old xcassets and added new xcassets by using Don't use app catalogs

0

In my case I am using cocoa pods. The cocoa pods script Pods-resources.sh somehow caused the problem. Removing the asset parts from the script solved the problem.

Make sure to clean your project and delete derived data folder.

Parts to be deleted can be found here:

https://stackoverflow.com/a/21309102/832111

Community
  • 1
  • 1
d.ennis
  • 3,445
  • 2
  • 28
  • 36
0

I upgraded to cocopods 0.37 and the problem was solved. If you used cocopods then it was probably its fault.

Qiulang
  • 10,295
  • 11
  • 80
  • 129