Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The image set name "xxx" is used by multiple image sets with localized Asset Catalog (.xcassets)

Tags:

xcode

ios

I would like to use one Images.xcassets directory for each language supported by my app.

So in the finder I put one Images.xcassets directory in each .lproj directory

enter image description here

enter image description here

In xCode I have:

enter image description here

For both the english and french xcassets they have english and french checked in localization field in xCode.

enter image description here

But when I compile I've got warnings for all my images in the Asset Catalogs:

The image set name "xxx" is used by multiple image sets

How can I correct the error ?

like image 588
Jean Lebrument Avatar asked Jul 03 '14 13:07

Jean Lebrument


2 Answers

You can't have two images with the same name on xcassets.

I found this because i had one image with this name 'default.png' for iPad and other with the same name for iPhone inside of a file of xcassets. The reason for your warning is because of this. Two images with the same name.

The solution is to have one image 'default.png' and inside configure the different devices that the image supports.

like image 81
mrodriguez Avatar answered Nov 16 '22 06:11

mrodriguez


I was doing something similar in wanting to swap out my app icons from different asset catalogs depending on whether I built debug, ad-hoc, or release. My solution was to not include the debug and ad-hoc catalogs in any targets, then write a run script in Swift to copy over those assets at runtime. Here's the script:

import Foundation

struct CopyNonReleaseIcons: Script {

    var usage: String {
        return "When running a non-release (Debug or AdHoc) build, switches out the app icon to help" +
            "differentiate between builds on the home screen.\n\n" +
            "Usage: swift CopyNonReleaseIcons.swift <CONFIGURATION> <PRODUCT_NAME> <BUILD_PATH>"
    }

    var expectedNumberOfArguments = 3

    func run(arguments arguments: [String]) {
        let configuration = arguments[0]
        let productName = arguments[1]
        let buildPath = arguments[2]

        if configuration == "Debug" || configuration == "AdHoc" {
            copyIcons(buildName: configuration, productName: productName, buildPath: buildPath)
        }
    }

    func copyIcons(buildName buildName: String, productName: String, buildPath: String) {
        let sourcePath = "My App/Resources/Asset Catalogs/" + productName + "SpecificAssets-" + buildName + "Icons.xcassets/AppIcon.appiconset/"

        var appName = "My App.app"
        if (productName == "White Label") {
            appName = "White Label.app"
        }

        shell(launchPath: "/bin/cp", arguments: ["-rf", sourcePath, buildPath + "/" + appName])
    }
}

CopyNonReleaseIcons().run()
like image 45
Luke Avatar answered Nov 16 '22 07:11

Luke