Unable to set submenu for NSMenuItem (FinderSync extension)

I've upgraded the project to Swift 2.0, and finally made a working submenu. Posting the solution:

override func menuForMenuKind(menuKind: FIMenuKind) -> NSMenu! {
    let main = NSMenu()
    let submenu = NSMenu()
    let mainDropdown = NSMenuItem(title: "Some option group", action: nil, keyEquivalent: "")
    main.addItem(mainDropdown)
    m.setSubmenu(submenu, forItem: mainDropdown)


    submenu.addItem(NSMenuItem(title: "Option 1", action: nil, keyEquivalent: ""))
    submenu.addItem(NSMenuItem(title: "Option 2", action: nil, keyEquivalent: ""))
    return main
}

This will only work on Mac OS 10.11+, 10.10.5 still has the bug being unable to generate a submenu. So a good appraoch is generating a flat menu for < 10.11, and a cascade starting from el capitan.