Xcode project with multiple targets and multiple assets catalogs
Asked Answered
H

1

11

I have a project with two targets: target A and target B. This targets generate app which are "equal" but whit different skins (different colors and images)

For this, the project has two Asset Catalogs, which are identical but have different images insides. Each Asset catalog is assigned to the corresponding target.

This works perfectly and I can generate both applications, but while editing the Storyboards and assigning the images I can only see the images from the first Asset Catalog.

Is there any way to see or "preview" the storyboards with the different Catalogs?

Henryk answered 12/4, 2016 at 9:5 Comment(3)
Are you able to solve this?Introit
Nop, couldn't find a wayHenryk
I found this article, probably it could help? matt.coneybeare.me/…Doyen
A
2

We can have multiple asset catalogs.

We are having ‘Alphabets’ project and in this project, we are having three targets - three applications. A, B and C.

Now default one is ‘Assets.xcassets’ which is in the main directory.

For ex: My Projects/Alphabets/Assets.xcassets - All Targets

You can create as many as xcassets in hierarchy also. Listed some examples below.

My Projects/Alphabets/One/A/1A.xcassets - A Target

My Projects/Alphabets/Two/B/2B.xcassets - B Target

My Projects/Alphabets/Three/C/3C.xcassets - C Target

When you are adding any resource to this xcassets, make sure that the name which is displayed in Xcode and the actual image name when you have added it are same. After that you will be able to user it using the image name method.

if target == "A" {
   let imageView = UIImageView(image: UIImage(named: "a"))
}
if target == "B" {
  let imageView = UIImageView(image: UIImage(named: "b"))
}
if target == "C" {
  let imageView = UIImageView(image: UIImage(named: "c"))
}

Please check screenshots attached here.

First Step

Second Step

Third Step

Alexi answered 10/10, 2018 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.