title: NSFontAttributeName vs NSAttributedStringKey.font
body: <p>I am having some trouble with Swift code in a library I have been using for a while.
  It seems related to some kind of version conflict, but I am not sure.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>let attribMsg = NSAttributedString(string: msg,
                                 attributes: [NSAttributedStringKey.font:UIFont.systemFont(ofSize: 23.0)])
  </code></pre>
  
  <p>Here is the error message I get from the compiler: </p>
  
  <pre><code>Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
      Did you mean 'zone'?  Fix(button)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ppno6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ppno6.png" alt="enter image description here"></a></p>
  
  <p>Using this code in different project I noticed that on some of them I do not get the error message and it all compiles without any problem.</p>
  
  <p>I also noticed that if I replace the above code by the following:</p>
  
  <pre><code>let attribMsg = NSAttributedString(string: msg,
                                 attributes: [NSFontAttributeName:UIFont.systemFont(ofSize: 23.0)])
  </code></pre>
  
  <p>The projects with a problem will work while the others(previously working) show this other message:</p>
  
  <pre><code>'NSFontAttributeName' has been renamed to 'NSAttributedStringKey.font'
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/doWOs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/doWOs.png" alt="enter image description here"></a></p>
  
  <p>In other words some projects work with one type of code and some others work with the other type.</p>
  
  <p>Needless to say that I do not want to change the code each time I switch from one project to another.</p>
  
  <p>The experiments I made changing the Deployment Target of the project do not seem to make much difference.
  So comes my question: <strong>What is the way to handle this issue?</strong></p>