iosxcodeimagexcasset

Xcode -using two xcassets how would i override


Let me explain the architecture i'd like to build in xCode. here is a photo of xcassets i have created in the project structure:

enter image description here

From the image you can see that i have created two xcassets folders. The first one called images.xcassets hosts all images that are common to both my targets.Its membership is in both target1 and target2. This xcassets sheet is filled with many images which i inherited from a fork.

The images-override.xcassets folder on the other hand, is where i'd like to put any images that ARE NOT common to both my targets. So the target membership for this directory should be only target2.

What im trying to accomplish: Doing it this way, if i attempt to retrieve an image called myImage.png it should first check the images-override to see if any image is overriden, if its not found there it should then check images.xcassets for the image.

So my question is about what order the images will get searched for. I'd like the project to first check the images-overriden.xcassets sheet then check (if necessary) the images.xcassets folder. Any ideas ?


Solution

  • In general, you cannot include multiple assets with the same name in Xcode. For your purpose, I'd recommend a naming convention:

    filename.png filename-override.png

    For example. When loading your image, you first check if filename-override.png exists, if so load it. If not, load filename.png.