Help us understand the problem. What is going on with this article?

VVDocumenterSettingがクラッシュしたので

More than 3 years have passed since last update.

Xcodeで見栄えするコメントを挿入してくれることで便利なプラグインVVDocumenterSettingがクラッシュしました。

事象はコメント自動挿入時(///と入力した時)、何も言わずにXcodeごとクラッシュするという。。(クラッシュログを記事一番最後に載せています)

ソースを追ってみると、SDKが古かったことが根本原因と分かりました。
環境は下記で、

Xcode:6.1
MacOSのバージョンが10.9(Mavericks)

クラッシュしたのは「VVDocumenterSetting.m」の
「-(NSInteger) keyVCodet;」にある
「localizedCaseInsensitiveContainsString」
というNSStringのメンバメソッド。

これがMacOSのバージョン10.10(MacOSX Yosemite)からしか対応していないのに、自分の環境が10.9だったためSDKが古く、メソッドが見つからなかったみたいです。

なので、下記のようにメソッドをコメント化して対応しました。

VVDocumenterSetting.m
-(NSInteger) keyVCode
{
//    TISInputSourceRef inputSource = TISCopyCurrentKeyboardLayoutInputSource();
//    NSString *layoutID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceID);
//    CFRelease(inputSource);
//
//    // Possible dvorak layout SourceIDs:
//    //    com.apple.keylayout.Dvorak (System Qwerty)
//    // But exclude:
//    //    com.apple.keylayout.DVORAK-QWERTYCMD (System Qwerty ⌘)
//    //    org.unknown.keylayout.DvorakImproved-Qwerty⌘ (http://www.macupdate.com/app/mac/24137/dvorak-improved-keyboard-layout)
//    if ([layoutID localizedCaseInsensitiveContainsString:@"dvorak"] &&
//       ![layoutID localizedCaseInsensitiveContainsString:@"qwerty"]) {
//        return kVK_ANSI_Period;
//    }
//
//    // Possible workman layout SourceIDs (https://github.com/ojbucao/Workman):
//    //    org.sil.ukelele.keyboardlayout.workman.workman
//    //    org.sil.ukelele.keyboardlayout.workman.workmanextended
//    //    org.sil.ukelele.keyboardlayout.workman.workman-io
//    //    org.sil.ukelele.keyboardlayout.workman.workman-p
//    //    org.sil.ukelele.keyboardlayout.workman.workman-pextended
//    //    org.sil.ukelele.keyboardlayout.workman.workman-dead
//    if ([layoutID localizedCaseInsensitiveContainsString:@"workman"]) {
//        return kVK_ANSI_B;
//    }

    return kVK_ANSI_V;
}

やっていることはキーボード配列を取得 → ペースト(cmd+V)のキーコードを取得
としたいようです。

自分はMacBook Pro単体でしかXcodeを使用しないので、キーボード配列がコロコロ変わることはありません。ベタ書きでも構いません。なのでreturn kVK_ANSI_V;だけ残す対処にしました

このプラグイン、コメント文の挿入のために、クリップボードを経由していることがわかりました。

また根本対処としてはXcodeの新しいバージョンをインストールするほうが正解だと思います。

クラッシュログ
Process:         Xcode [33105]
Path:            /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:      com.apple.dt.Xcode
Version:         6.1 (6604)
Build Info:      IDEFrameworks-6604000000000000~2
App Item ID:     497799835
App External ID: 752282650
Code Type:       X86-64 (Native)
Parent Process:  launchd [281]
Responsible:     Xcode [33105]
User ID:         501

Date/Time:       2016-02-27 19:23:14.839 +0900
OS Version:      Mac OS X 10.9.4 (13E28)
Report Version:  11

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
ProductBuildVersion: 6A1052d
UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[__NSCFString localizedCaseInsensitiveContainsString:]: unrecognized selector sent to instance 0x7fb8169ddd10
UserInfo: (null)
Hints: None
Backtrace:
  0  0x00007fff950cc244 __exceptionPreprocess (in CoreFoundation)
  1  0x000000010e5b82f4 DVTFailureHintExceptionPreprocessor (in DVTFoundation)
  2  0x00007fff939cae75 objc_exception_throw (in libobjc.A.dylib)
  3  0x00007fff950cf12d -[NSObject(NSObject) doesNotRecognizeSelector:] (in CoreFoundation)
  4  0x00007fff9502a272 ___forwarding___ (in CoreFoundation)
  5  0x00007fff95029df8 _CF_forwarding_prep_0 (in CoreFoundation)
  6  0x000000011d7d7ab9 -[VVDocumenterSetting keyVCode] (in VVDocumenter-Xcode)
  7  0x000000011d7c9b56 -[VVDocumenterManager textStorageDidChange:] (in VVDocumenter-Xcode)
  8  0x00007fff9509ae0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
  9  0x00007fff94f8e82d _CFXNotificationPost (in CoreFoundation)
 10  0x00007fff9454f7ba -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
 11  0x000000010e598d1e -[NSNotificationCenter(DVTNSNotificationCenterAdditions) _dvt_postNotificationName:object:userInfo:] (in DVTFoundation)
 12  0x00007fff8f49a1b4 -[NSTextView(NSSharing) didChangeText] (in AppKit)
 13  0x000000010ea618bc -[DVTSourceTextView didChangeText] (in DVTKit)
 14  0x00007fff8f4972c2 -[NSTextView insertText:replacementRange:] (in AppKit)
 15  0x000000010ea61529 -[DVTCompletingTextView insertText:replacementRange:] (in DVTKit)
 16  0x00007fff8f4cc177 -[NSTextView insertText:] (in AppKit)
 17  0x000000010ea60de7 -[DVTSourceTextView insertText:] (in DVTKit)
 18  0x00007fff8f4966c7 -[NSTextInputContext insertText:replacementRange:] (in AppKit)
 19  0x00007fff8f495978 -[NSTextInputContext handleTSMEvent:] (in AppKit)
 20  0x00007fff8f493905 _NSTSMEventHandler (in AppKit)
 21  0x00007fff94c4f1d4 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) (in HIToolbox)
 22  0x00007fff94c4e787 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) (in HIToolbox)
 23  0x00007fff94c62880 SendEventToEventTarget (in HIToolbox)
 24  0x00007fff94ca3d0d SendTSMEvent (in HIToolbox)
 25  0x00007fff94ca389b SendUnicodeTextAEToUnicodeDoc (in HIToolbox)
 26  0x00007fff94ca3595 TSMKeyEvent (in HIToolbox)
 27  0x00007fff94c902b7 TSMProcessRawKeyEvent (in HIToolbox)
 28  0x00007fff8f493150 -[NSTextInputContext handleEvent:] (in AppKit)
 29  0x00007fff8f4729dd -[NSView interpretKeyEvents:] (in AppKit)
 30  0x00007fff8f492d6d -[NSTextView keyDown:] (in AppKit)
 31  0x00007fff8f43f56b -[NSWindow sendEvent:] (in AppKit)
 32  0x000000010f81a54b -[IDEWorkspaceWindow sendEvent:] (in IDEKit)
 33  0x00007fff8f3e0b32 -[NSApplication sendEvent:] (in AppKit)
 34  0x000000010f5c37f4 -[IDEApplication sendEvent:] (in IDEKit)
 35  0x00007fff8f2309f9 -[NSApplication run] (in AppKit)
 36  0x00007fff8f21b783 NSApplicationMain (in AppKit)
 37  0x00007fff89ee25fd start (in libdyld.dylib)
 38  0x0000000000000001
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした