ルビ付きのNSAttributedStringを使うとiOS8でBAD_ACCESSが発生する

原因としてはルビに空文字を設定してるのが悪いっぽい。

たとえばこんな感じ

// 空文字をルビとして設定する
let ruby = ""
var textRef: [Unmanaged<CFString>?] = [Unmanaged<CFString>.passRetained(ruby as CFString) as Unmanaged<CFString>, .none, .none, .none]
let annotation = CTRubyAnnotationCreate(.auto, .auto, 0.5, &amp;textRef[0]!)
                
let attributedString = NSAttributedString(
                    string: "漢字",
                    attributes: [kCTRubyAnnotationAttributeName as String: annotation]

// ↓ ここでEXC_BAD_ACCESSが発生する
let line = CTLineCreateWithAttributedString(attributedString)

 

ほかにも

let framesetter = CTFramesetterCreateWithAttributedString( attributedText)

// ↓ ここでEXC_BAD_ACCESSが発生する
let frame = CTFramesetterCreateFrame(framesetter, CFRange(), path, nil)

ちなみにiOS10じゃ発生しないよ。