0

I'm trying to create two applications from same codebase. These application will have same functionality but different logos, app name etc. I have created two targets with different bundle Ids so now I get unique apps when running each target.In my app, I have a viewcontroller with an UIImageView. Now I want to assign an image to UIImageView based on the running target. So I created two assets folders.

  • Target1 -> Assest1 -> logo.png
  • Target2 -> Assest2 -> logo.png

logo.png is different file with same name.

How can I assign the correct logo.png to uiimageview based on the running target? Your help is appreciated.

Lak
  • 381
  • 1
  • 5
  • 23
  • 1
    The XCAsset you created should be either within target 1 or within target 2, check the "Target Membership" of it. See https://stackoverflow.com/questions/43911642/using-the-same-code-for-different-target-in-xcode – Larme Jun 10 '21 at 07:54

1 Answers1

0

Ensure that your asset is in the correct target an then use the following method:

UIImage(named: "example", in: Bundle(for: YourClass.self), with: nil)

To obtain your bundle you could use your class to refer to your bundle:

Bundle(for: YourClass.self)
rickramirr
  • 19
  • 3