No color named '...' found in asset catalog for /private/var/containers/Bundle/Application/
Asked Answered
N

1

8

I think this is a bug, it only appears when I try to access a custom color in the Assets Catalog. The color is displayed correctly but I have an error in the console.

No color named '...' found in asset catalog for /private/var/containers/Bundle/Application/...

This only happens in views with Charts (I use the same assets in all the app and don't get this message.), and on device with the new iOS18 Beta. On simulator with other versions I don't have this problem.

The weirdest part is I only get the error about textColors not bgColors. (See the next example)

enum ColorPicked: Codable, CaseIterable, Identifiable {
    var id: String { return self.bgColor.description }
    case white
    case red
    
    var textColor: Color {
        switch self {
        case .red: return .textBetterRed
        case .white: return .textBetterWhite
        }
    }

    var bgColor: Color {
        switch self {
        case .white: return .betterWhite
        case .red: return .betterRed
        }
    }    
}

import SwiftUI
import Charts

struct Chart1: View {

    let data: [ChartData1]
    let color: ColorPicked
var body: some View {
        ZStack{
            VStack(alignment: .leading){
                Text("Chart Title")
                    .foregroundStyle(color.textColor)
...
}.background(color.bgColor)
}
}
}
Neubauer answered 17/6 at 21:1 Comment(6)
I'm also facing the same issue! Did you get any solution for this one?Salsbury
Not yet. But it seems to me that is just a bug because it does not happen if it’s not in the beta of iOS 18. I am waiting to see if is still happening on the official version.Neubauer
I am seeing the same from a device running the iOS18 beta (currently on beta 3)Schwa
I’ve noticed the same for .fill() in Xcode 16.0 beta 6 (16A5230g). Just reported a feedback, if you want to join and reference: FB14907314Joannjoanna
This is still an issue for me with the RC version. It's making debugging impossible... Has anyone found any kind of workaround?Schwa
Looks like this is fixed in iOS 18.1 beta 4Schwa
M
3

The workaround is to use Color(uiColor:). This issue also affects ImageRenderer. I’m using it for PDF generation, and colors from the asset catalog don’t display in the resulting PDF

Martinic answered 11/9 at 9:30 Comment(2)
This is great as a workaround until Apple fix the problem. Thanks a million!Schwa
Update: Just noticed that weirdly this workaround only works if the device in a portrait orientation. If the device is held landscape the re-drawn chart generates the errors again....Schwa

© 2022 - 2024 — McMap. All rights reserved.