🐞 Segfault when using asset catalog colors
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start with ContentView.swift in the linked EditorThemeReproduction.zip and reproduce the launch segfault using the asset-catalog NSColor values, especially NSColor.editorBackground. Compare the failing EditorTheme construction with the working usingColorSpace(.sRGB) case. Done means asset-catalog colors can define an EditorTheme without an explicit color-space conversion and the reproduction app launches without a segfault.
Written by the indexing model from the issue text.
Description
Description
When creating an EditorTheme from asset catalog colours, a segfault occurs at launch unless the background colour is explicitly cast to sRGB (NSColor.editorBackground.usingColorSpace(.sRGB)!).
To Reproduce
- Create a new SwiftUI macOS app
- Add CodeEditSourceEditor as a dependency
- Add sRGB colors sets to the Asset catalog
- Use those colors through NSColor to define an EditorTheme (e.g.
NSColor.editorBackground) - Launch the app
- Something segfaults
- If you set the background to
NSColor.editorBackground.usingColorSpace(.sRGB)!, it doesn't
Expected Behavior
It should be possible to use colours from the asset catalog to define the theme colours without additional hijinks.
Version Information
CodeEditSourceEditor: 0.15.2
macOS: 15.7.4
Xcode: 26.3
Additional Context
Minimal reproduction project: EditorThemeReproduction.zip (ContentView.swift contains all the relevant code.)
How I'm creating the theme (the asset catalog is included with the above project):
extension EditorTheme {
/// Creates an ``EditorTheme`` from colors defined in the asset catalog.
static func fromAssetCatalog() -> Self {
EditorTheme(
text: EditorTheme.Attribute(color: NSColor.editorText),
insertionPoint: NSColor.editorInsertionPoint,
invisibles: EditorTheme.Attribute(color: NSColor.editorInvisibles),
// This segfaults:
background: NSColor.editorBackground,
// This does not, despite the asset catalog color sets being defined as sRGB
// background: NSColor.editorBackground.usingColorSpace(.sRGB)!,
lineHighlight: NSColor.editorLineHighlight,
selection: NSColor.editorSelection,
keywords: EditorTheme.Attribute(
color: NSColor.editorKeywords,
bold: true
),
commands: EditorTheme.Attribute(color: NSColor.editorCommands),
types: EditorTheme.Attribute(color: NSColor.editorTypes),
attributes: EditorTheme.Attribute(color: NSColor.editorAttributes),
variables: EditorTheme.Attribute(color: NSColor.editorVariables),
values: EditorTheme.Attribute(color: NSColor.editorValues),
numbers: EditorTheme.Attribute(color: NSColor.editorNumbers),
strings: EditorTheme.Attribute(color: NSColor.editorStrings),
characters: EditorTheme.Attribute(color: NSColor.editorCharacters),
comments: EditorTheme.Attribute(color: NSColor.editorComments)
)
}
}
Screenshots
- Dominant language
- Swift
- Stars
- 720
- Forks
- 162
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CodeEditApp/CodeEditSourceEditor
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
CodeEditApp/CodeEditSourceEditor#377 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
CodeEditApp/CodeEditSourceEditor#376 · 1 comment ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
CodeEditApp/CodeEditSourceEditor#378 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
All issues in CodeEditApp/CodeEditSourceEditor
Similar issues
-
area:dictation documentation P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
uttrflow/uttrflow-swift#1180 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
OneBusAway/onebusaway-ios#1451 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100