When the current project is a git repository, this will show the currently checked-out branch as a subtitle. Once a tap is registered, a popup will appear displaying the currently checked-out branch and all other local branches.
This view should be set to the view property in a NSToolbarItem.
First make sure a WorkspaceDocument is accessible in the context.
var workspace: WorkspaceDocument?Then in
toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:),
create a new NSToolbarItem:
let toolbarItem = NSToolbarItem(itemIdentifier: /* Identifier */)
// create a NSHostingView
let view = BranchPickerToolbarItem(workspace?.workspaceClient)
let hostingView = NSHostingView(rootView: view)
// set the view property of the toolbar item
toolbarItem.view = hostingView
// return the toolbar item
return toolbarItem