Creating a color from a color set indicated by name not working

import SwiftUI

struct Temp: View {
    var body: some View {
        Text("yellow")
            .background(Color("yellow"))
    }
}

#Preview {
    Temp()
}

Things like this cannot work well:

Since it is allowed to change the color by giving a string that indicates the name:

and also from other project I have found that it can correctly work:

so I am confused.....

In order to use Color("yellow") you need to have a Color in your Asset catalog called yellow.

I'll wager that in your 'poppy' project there's an Asset catalog with a Color called poppy, which is why it works.

If you just want to use the colour yellow, just use Color.yellow (or just .yellow if the receiver is expecting a Color object).

Creating a color from a color set indicated by name not working
 
 
Q