I have created a IOS Application in XCode 15.2 (15C500b) which causes issue not able to see previews.
In the Assets.xcassets folder I have created a ThemeColors which contains 5 Color Sets. I had used these in another Swift Project, and also used these same color sets in the second project. The First Project name was WC. The Second Project name is WCCardDemo stored in a different project folder.
Now when I copy or retype these color sets into the Project WCCardDemo, I get the following warnings in
Multiline
^ WCCardDemo X Command compiledAssetCatalog failed with nonzero exit code
-
The "GreenColor" color asset name resolves to a conflicting UI symbol "green. Try renaming the asset.
-
The "RedColor" color asset name resolves to a conflicting UI symbol "red. Try renaming the asset.
BlockQuote
When I try to refresh the startup default ContentView I get Failed to build the scheme WC
Content View
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
Color.theme.background.ignoresSafeArea()
VStack {
Text("Accent Color")
.foregroundColor(Color.theme.accent)
Text("Seconday Text Color")
.foregroundColor(Color.theme.secondaryText)
Text("Red Color")
.foregroundColor(Color.theme.red)
Text("Green Color")
.foregroundColor(Color.theme.green)
}
}
.padding()
}
}
#Preview {
ContentView()
}
code-block
I also get the GeneratedAssetSymbols file displayed !! <GeneratedAssetSymbols.swift>
...
extension DeveloperToolsSupport.ColorResource {
...
/// The "BacktgroundColor" asset catalog color.
static var backtground: UIKit.UIColor {
#if !os(watchOS)
.init(resource: .backtground)
#else
.init()
#endif
}
#warning("The \"GreenColor\" color asset name resolves to a conflicting UIColor symbol \"green\". Try renaming the asset.")
#warning("The \"RedColor\" color asset name resolves to a conflicting UIColor symbol \"red\". Try renaming the asset.")
code-block
This appears to me to be xCode bug, and not a coding issue. I am asking if reusing assets and color sets File names in multple swift projects is bad practice. This does not make sense to me, that I can not reuse color set files ???. The first time I used the RedColor colorset name it was no issue. If i use it again in another separate Swift Project I get compile errors ??? Clean project does not fix this issue.
Thanks in Advance for any Information of best pratices, or what issue I am having.
I found an explanation on Hacking With Swift website. This web site is for Learning Swift and as far as I can see, it is a safe website which provided the solution to my issue. I am not able to post that link here.
In my case the warning is destructive and causes runtime issues and also issue with the preview failing I have set flag to false and this appears to have resolved this runtime issue.
What I read is this appears to be a feature added in xCode 15. This setting is found under Asset: Catalog Compiler - Options The switch is Generate Asset Symbols = false. It has a default of yes.
When I have more time I will look deeper into this feature. I would have issues in my development style, if this was not a build setting.
Thanks for any more details, if you happen to know more about this feature..