title: Codable extension to CoreLocation classes
body: <p>I need to add <code>Codable</code> to two classes. One is <code>CLLocationCoordinate2D</code> and the second one <code>CLCircularRegion</code>.</p>
  
  <p>I have no issue with <code>CLLocationCoordinate2D</code> and it works by doing that:</p>
  
  <pre><code>extension CLLocationCoordinate2D: Codable {
      public enum CodingKeys: String, CodingKey {
          case latitude
          case longitude
      }
  
      public func encode(to encoder: Encoder) throws {
          var container = encoder.container(keyedBy: CodingKeys.self)
          try container.encode(latitude, forKey: .latitude)
          try container.encode(longitude, forKey: .longitude)
          }
  
      public init(from decoder: Decoder) throws {
          let values = try decoder.container(keyedBy: CodingKeys.self)
          latitude = try values.decode(Double.self, forKey: .latitude)
          longitude = try values.decode(Double.self, forKey: .longitude)
      }
  }
  </code></pre>
  
  <p>But I have a lot of issues trying to do the same thing with <code>CLCircularRegion</code>. Since <code>radius</code> and <code>center</code> are read-only properties I cannot really create them in the same way. The other problem is why I was able to create <code>public init</code> in <code>CLLocationCoordinate2D</code> and for <code>Codable</code> extension in <code>CLCircularRegion</code> I'm getting error:</p>
  
  <p><a href="https://i.stack.imgur.com/Z02Tl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z02Tl.png" alt="enter image description here"></a></p>
  
  <p>I see the point of public, but required? And of course <code>required</code> will fail beacouse it's extension not a class. So one solution for this issue will be create abstraction class that will contain all fields and build region in initializer I know that, but there is any other way to extend <code>Codable</code> to existing class that's not support by Apple yet?</p>