title: Swift 4 - Xcode 9 beta 4 - NSKernAttributeName vs NSAttributedStringKey
body: <p>iOS Deployment Target: iOS 9.3,
  Base SDK: Latest iOS (iOS 11.0),
  Xcode 9 Beta 4,
  Swift 4</p>
  
  <p>The following code builds and runs in Swift 3, Xcode 8:</p>
  
  <pre><code>    let kern = (CTRunGetAttributes(run) as? [String : Any])?
  [NSKernAttributeName] as? CGFloat ?? 0
  </code></pre>
  
  <p>However, the Swift 4 migrator converts it to this:</p>
  
  <pre><code>    let kern = (CTRunGetAttributes(run) as? [String : Any])?
  [NSAttributedStringKey.kern] as? CGFloat ?? 0
  </code></pre>
  
  <p>Xcode 9 now complains:</p>
  
  <pre><code>Cannot subscript a value of type '[String : Any]' with an index of type 'NSAttributedStringKey'
  </code></pre>
  
  <p>According to the inspector, '<code>NSAttributedStringKey</code>' is only available in iOS 11. (Keep in mind that I am targeting iOS 9).</p>
  
  <p>If I replace '<code>NSAttributedStringKey.kern</code>' with '<code>NSKernAttributeName</code>', the error remains. </p>
  
  <p>Command-clicking on '<code>NSKernAttributeName</code>' tells me that its availability is iOS 6. However, the inspector also claims its type is '<code>NSAttributedStringKey</code>', which is only available in iOS 11. I do not know if this is merely an artefact of the API presentation, or a stuff-up, or something I'm missing.</p>
  
  <p>Question: how can I use <code>NSKernAttributeName</code> (or its modernised version) with backward compatibility to iOS 9, with Swift 4?  </p>
  
  <p>Thank you for any help.</p>