swiftsafari-extensionsafari-app-extension

How to call the popover to show up in Safari app extension?


I am developing a safari app extension with swift in xcode.
In my SafariExtensionHandler.swift, I declared a func:

    override func popoverViewController() -> SFSafariExtensionViewController {
        return SafariExtensionViewController.shared
    }

and in my SafariExtensionViewController.swift,

class SafariExtensionViewController: SFSafariExtensionViewController {

    static let shared: SafariExtensionViewController = {
        let shared = SafariExtensionViewController()
        shared.preferredContentSize = NSSize(width:320, height:240)
        return shared
    }()

}

However, when I click the icon in my safari toolbar, nothing shows up and no errors. Anyone helps? I am fresh to safari app extension and apple-family developing.


Solution

  • Damn I figured that out.
    In info.plist, SFSafariToolbarItem dict, change the value of action key to Popover .