title: Plist encoding and decoding back to Dictionary [String:Decodable]
body: <p>I want to be able to save Dictionary of type [String:Codable] to plist and recover back as same. I tried this but it throws errors:</p>
  <pre><code>  let dictionary:[String:Any] = [&quot;point&quot;:CGPoint(1,1), &quot;value&quot;: 10, &quot;key&quot; : &quot;testKey&quot;] 
  
     do { 
          let url = FileManager.default.temporaryDirectory.appendingPathComponent(&quot;test.plist&quot;)
          try savePropertyList(dictionary, toURL: url)
          buildFromPlist(url)
        } catch {
          print(error)
      }
    
  
  
      private func savePropertyList(_ plist: Any, toURL url:URL) throws
     {
      let plistData = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
      try plistData.write(to: url)
     }
  
    private func buildFromPlist(_ url:URL)
    {
         do {
            let data = try Data(contentsOf: url)
            let decoder = PropertyListDecoder()
            let dictionary = try decoder.decode([String:Decodable], from: data)
            NSLog(&quot;\(dictionary)&quot;)
        } catch {
             NSLog(&quot;Error decoding \(error)&quot;)
        }
     
      
     }
  </code></pre>
  <p>But I get build errors in decode function:</p>
  <pre><code>  Value of protocol type 'Decodable' cannot conform to 'Decodable'; only struct/enum/class types can conform to protocols
  </code></pre>
  <p>I wonder how I read back the dictionary I saved to plist file?</p>
  <p>EDIT: Even savePropertyList fails at runtime with objects such as CGPoint and CGAffineTransform with the error -</p>
  <pre><code> &quot;Property list invalid for format: 100 (property lists cannot contain objects of type 'CFType')&quot; UserInfo={NSDebugDescription=Property list invalid for format: 100 (property lists cannot contain objects of type 'CFType')}
  </code></pre>
  <p>I wonder how can we write Codable objects to plist and recover back?</p>