XcodeでRubyCocoaプロジェクトを実行すると"invalid option"とログに出力され起動しない
現象
@casualconc さんから「RubyCocoaのプロジェクトをビルドして実行するとinvalid option -Nとでる」とのこと。アプリ単独では実行できるが、Xcodeからの実行ができない。
調査
ぴんときた。
% ruby -N ruby: invalid option -N (-h will show valid options)
んー、これですな。RubyCocoaでは、.app実行時に渡されたオプションをrubyのコマンドラインオプションとして解釈するように設計されている(RBApplicationMain()を使っている場合のみ)。なのでXcodeがオプションを渡して実行してしまって、それがrubyにない値だとエラーになってしまう。リフジン。
確認するために新規プロジェクトを作成して、実行時の引き数を出力してXcode 4.2で実行みる。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSProcessInfo * info = [NSProcessInfo processInfo]; NSLog(@"number of arguments: %lu", [[info arguments] count]); [[info arguments] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSLog(@"arguments[%lu]: %@", idx, obj); }]; }
出力はこんな感じ。
[62066:707] number of arguments: 3 [62066:707] arguments[0]: /.../A.app/Contents/MacOS/A [62066:707] arguments[1]: -NSDocumentRevisionsDebugMode [62066:707] arguments[2]: YES
ということで"-NSDocumentRevisionsDebugMode YES"というのが渡されているようだ。これは、SchemeのRun>Options tab: "allow debugging when using document Versions Browser"のオンオフで制御できるけれど初期値がオンみたい。
さて、Apple側でこれに関した情報はないかと見てみると、Mac OS X Lion Release Notes
Cocoa Application Frameworkの"NSDocument Autosaving In Place"にそれっぽい記述がある。
Since the version browser interface takes control of the entire screen,ほかにも"-NSTableRowViewShowRows YES"や"-NSOutlineViewValidateChanges YES"を渡すと…的な記述があるので同類なのでしょう。
you can set the NSDocumentRevisionsDebugMode user default to YES for
easier debugging of your application in this interface.