俺のxcodeがibeaconを 発信しながらgistに投稿できるわけがない
DESCRIPTION
2014/3/12 iOS_LT #8 発表資料TRANSCRIPT
スタバで呪文 (10万DL突破)
Xcode Plugin カッコイイなー
イケてるなー
いいなー
そうだ、 作ってみよう!
プラグイン開発 のポイント
プラグインは シングルトン
+ (void)pluginDidLoad:(NSBundle *)plugin { static id sharedPlugin = nil; static dispatch_once_t onceToken; NSString *currentApplicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"]; if ([currentApplicationName isEqual:@"Xcode"]) { dispatch_once(&onceToken, ^{ sharedPlugin = [[self alloc] initWithBundle:plugin]; }); } }
メニュー作成
- (id)initWithBundle:(NSBundle *)plugin { if (self = [super init]) { self.bundle = plugin; NSMenuItem *menuItem = [[NSApp mainMenu] itemWithTitle:@"Edit"]; if (menuItem) { [[menuItem submenu] addItem:[NSMenuItem separatorItem]]; NSMenuItem *actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Gistに投稿" action:@selector(alertMYM) keyEquivalent:@"-"]; actionMenuItem.keyEquivalentModifierMask = NSCommandKeyMask | NSShiftKeyMask; [actionMenuItem setTarget:self]; [[menuItem submenu] addItem:actionMenuItem]; } [self setUpNotification]; } return self; }
この辺はお決まり
テンプレ使おう
https://github.com/kattrali/Xcode5-Plugin-Template
おく
~/Library/Developer/Xcode/Templates/Project Templates/
Application Plug-in/
イニシャライザで 監視設定
- (void)setUpNotification { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewDidChangeSelection:) name:NSTextViewDidChangeSelectionNotification object:nil]; }
- (void)textViewDidChangeSelection:(NSNotification *)notification { NSTextView *textView = (NSTextView *)[notification object]; self.textView = textView; }
ごにょごにょと いい感じにいじる
どうやってごにょるの?
公開されているプラグインのコードを読む
プラグインの使い方
command + B
Xcode再起動
消したいとき
command + shift + k
Xcodeちゃんが 死亡した場合
直接削除
~/Library/Application Support/Developer/
Shared/Xcode/Plug-ins/
つくったもの
・Gist投稿プラグイン ・iBeacon発信プラグイン ・♡♡♡投稿プラグイン
・Gist投稿プラグイン ・iBeacon発信プラグイン ・♡♡♡投稿プラグイン
・shortcut追加プラグイン ・iBeacon発信プラグイン ・♡♡♡投稿プラグイン
♡♡♡は内緒
GistのOAuth認証めんどくさかったのでプルリクください
デモ
公開!
https://github.com/tochiba/TSKAddShortCutKeyXcodePlugin
!
https://github.com/tochiba/TSKiBeaconXcodePlugin
プルリク お待ちしてます
ありがとうございました