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
In xCode I have:
For both the english and french xcassets they have english and french checked in localization field in xCode.
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 ?
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.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With