<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Debugging on Mike Gopsill</title>
    <link>https://www.mikegopsill.com/categories/debugging/</link>
    <description>Recent content in Debugging on Mike Gopsill</description>
    <generator>Hugo -- 0.157.0</generator>
    <language>en</language>
    <lastBuildDate>Fri, 16 May 2025 09:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.mikegopsill.com/categories/debugging/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Stopping SetNSColor(CGContext*, void const*) Crashes in UIKit</title>
      <link>https://www.mikegopsill.com/posts/setnscolor-crash-uikit/</link>
      <pubDate>Fri, 16 May 2025 09:00:00 +0000</pubDate>
      <guid>https://www.mikegopsill.com/posts/setnscolor-crash-uikit/</guid>
      <description>&lt;h2 id=&#34;tldr&#34;&gt;TL;DR&lt;/h2&gt;
&lt;p&gt;I recently encountered a crash on &lt;code&gt;SetNSColor(CGContext*, void const*)&lt;/code&gt; with&lt;br&gt;
&lt;code&gt;[__SwiftValue CGColor]: unrecognized selector sent to instance&lt;/code&gt;. It took a while to find the root cause as the stack trace lacked a lot of detail. Ultimately it was a &lt;strong&gt;SwiftUI &lt;code&gt;Color&lt;/code&gt;&lt;/strong&gt; in a &lt;strong&gt;UIKit&lt;/strong&gt; API that expects a &lt;code&gt;UIColor&lt;/code&gt; (or raw &lt;code&gt;CGColor&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;In this case I passed a SwiftUI &lt;code&gt;Color&lt;/code&gt; via the &lt;code&gt;.foregroundColor&lt;/code&gt; attribute of an &lt;code&gt;NSAttributedString&lt;/code&gt; that UIKit then rendered.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
