【发布时间】:2016-12-03 16:25:25
【问题描述】:
我一直在尝试使用 MASShortcut 并按照那里的说明使用 cocoapods 添加它。然后我将它添加到我的 imported 它,但我一直收到错误
没有这样的模块'MASShortcut'
这是我的设置:
AppDelegate.swift:
import Cocoa
import Carbon
import MASShortcut
var kShortCut: MASShortcut!
@IBOutlet weak var shortcutView: MASShortcutView!
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
override func awakeFromNib() {
... omitted ...
}
override func viewDidLoad() {
super.viewDidLoad()
shortcutView.shortcutValueChange = { (sender) in
let callback: (() -> Void)!
if self.shortcutView.shortcutValue.keyCodeStringForKeyEquivalent == "k" {
self.kShortCut = self.shortcutView.shortcutValue
callback = {
print("K shortcut handler")
}
} else {
callback = {
print("Default handler")
}
}
MASShortcutMonitor.sharedMonitor().registerShortcut(self.shortcutView.shortcutValue, withAction: callback)
还有我的Podfile:
target 'myapp' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'MASShortcut', '~> 2'
# Pods for myapp
target 'myappTests' do
inherit! :search_paths
# Pods for testing
end
end
最后是 proj-Bridging-Header.h:
#import <Cocoa/Cocoa.h>
#import <MASShortcut/Shortcut.h>
【问题讨论】:
标签: swift xcode macos cocoa cocoapods