2

I have two targets in XCode. These are two products based on the same code base but some graphics are different. It's like white labeling. The images are stored in an xcassets folder. How do I localize this? Either localizing for a language or localizing per target is fine with me as the white labeling is per language actually.

I have checked in xcassets but I don't see an option to localize any image.

update: i think one way i could accomplish this is to create a new xcassets folder for my target so it might be called images-mytarget.xcassets. then in the target build phase i could alter the xcassets folder in the 'copy bundle resources' area to use my targets xcassets. I was able to do this successfully. This differentiates xcassets per target. resolved.

j2emanue
  • 60,549
  • 65
  • 286
  • 456

1 Answers1

-8

While there's (apparently) not currently a way to explicitly localize the xcassets file directly, you could localize the name of the asset to pull using your Localizable.strings file. For instance, say you have a graphic logo treatment for the main menu of a game that needs to be localized. You could put the localized logo treatments in the assets file with different names, add the names to your Localizable.strings file, and then fetch the appropriate image with code like this:

UIImage *img = [UIImage imageNamed:NSLocalizedString(@"MAIN_MENU_IMAGE", nil)];
aBilal17
  • 2,974
  • 2
  • 17
  • 23