Trevor Freeman
Trevor Freeman

Reputation: 115

Specify which .xcassets catalogue to use an image from in XIB

If I had:

When building:

Both images could be referred to as Image in code or IB files with the correct image showing up in the respective build App.

So far, so good. Now my problem:

When adding a UIImageView to a b.xib belonging only to target B and referring to Image in that UIImageView, it doesn’t actually show 2.png in the XIB display in Xcode but rather 1.png. Xcode should know that b.xib belongs to target B and that it should look out for Image in b.xcassets rather than a.xcassets (as a.xcassets has no membership with target B).

What can I do to design my layout with the correct Image (2.png)?

Is there a way to tell Xcode a namespace or specify the asset catalogue to take Image from? I tried b/Image and b.xcassets/Image.

PS: the same goes for two projects (with a single target each) in one workspace

Upvotes: 1

Views: 334

Answers (1)

matt
matt

Reputation: 535526

Basically, don’t do that. Don’t give the same name to image sets in different asset catalogs. As you have shown, it confuses Interface Builder.

You might be able to differentiate using asset catalog “folder” feature for name spacing but I have not found that to be totally reliable either.

Upvotes: 1

Related Questions