Oddbean new post about | logout
 For AppIntents and LocalizedStringResource, when you need to return a LocalizedStringResource, is there a way to do it dynamically? I'm guessing the answer is no, but switching over a ton of strings just to feed the same thing in feels really silly

https://files.mastodon.social/media_attachments/files/111/145/387/095/594/803/original/dfc0d377e2070a2a.png 
 @096d2c53 Pretty sure that's a no, because these are (or at least can be) extracted by the static analyzer. 
 @096d2c53 see, your problem there is really the raisins. 
 @096d2c53 macro territory? 
 @096d2c53 I just use a string literal with interpolation and it seems to work 
 @096d2c53 You can do “\(self.name)” I think? 
 @096d2c53 Compiler needs help understanding which init you’re trying to match I think.

Does:

return .init(title: .init(stringLiteral: name))

work for you? 
 @096d2c53 that color scheme is 🔥. Is it the default XCode one? 
 @096d2c53 Instead of a struct, enum, and switch tray a protocol and implement it in several structs or classes. 
protocol IceCream {
     var displayRep: DisplayRep {get}
}
struct ChocolateIceCream: IceCream {
    let name = "choco"
    var displayRep: DisplayRep { return .init(title: name)}
}
You could also save all IceCream flavors in a plist or something.