How can I tell Asset Catalog (.xcassets) to use th

2020-05-20 02:12发布

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

6条回答
萌系小妹纸
2楼-- · 2020-05-20 02:37

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

查看更多
forever°为你锁心
3楼-- · 2020-05-20 02:43

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.

查看更多
我只想做你的唯一
4楼-- · 2020-05-20 02:50

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

查看更多
不美不萌又怎样
5楼-- · 2020-05-20 02:51

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!

查看更多
该账号已被封号
6楼-- · 2020-05-20 02:52

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

查看更多
Root(大扎)
7楼-- · 2020-05-20 02:53

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

查看更多
登录 后发表回答