Drawing a word, with a box around one letter
You can get rid of the "unsafe bit casts", an CFArrayRef can 
be bridged to [CTLine] (resp. [CTRun]) directly (tested with Swift 3 and Swift 4).

If you know for
sure that there is at least one line with at least one run then
it would be:

let lines = CTFrameGetLines(frame) as! [CTLine]
let line = lines.first!
let runs = CTLineGetGlyphRuns(line) as! [CTRun]
let run = runs.first!


Otherwise use optional binding with if let or guard let.
A most defensive version would be

guard let lines = CTFrameGetLines(frame) as? [CTLine],
    let line = lines.first,
    let runs = CTLineGetGlyphRuns(line) as? [CTRun],
    let run = runs.first else { return }