title: How do I make an enum codable?
body: <p>I have a nested an <code>enum</code> inside a <code>struct</code> that I want to conform to <code>Codable</code>. How do I make the enum <code>codable</code> and therefore make the <code>struct</code> codable?</p>
  
  <p>Here is an example of what I have:</p>
  
  <pre><code>struct Person: Codable {
    var firstName: String
    var lastName: String 
    var favoriteColor: Color
  
    enum Color {
      case blue, red, green, yellow, pink, purple
    }
  }
  </code></pre>
  
  <p>Then, I get two errors :</p>
  
  <blockquote>
    <p>Type 'Person' does not conform to protocol 'Decodable'</p>
    
    <p>Type 'Person' does not conform to protocol 'Encodable'</p>
  </blockquote>
  
  <p>How can I fix this problem?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I have also tried conforming Color to Codable. Xcode adds these protocol stubs: </p>
  
  <pre><code>init(from decoder: Decoder) throws {
    &lt;#code#&gt;
  }
  func encode(to encoder: Encoder) throws {
    &lt;#code#&gt;
  }
  </code></pre>
  
  <p>What would I do with this?</p>