NSViewController.init() は同名の xib 読み込んでくれるんだねえアプリ名.HogehogeViewControllerにはならないのか. でsplitしてた (edited)If the view controller class name ends with the word ‘Controller’, as in MyViewController, it looks for a nib file whose name matches the class name without the word ‘Controller’, as in MyView.nib. It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is MyViewController, it looks for a MyViewController.nib file.MyView.nib にフォールバックするのはやりすぎだと思う。 override func viewDidLoad() { super.viewDidLoad() for column in tableView.tableColumns { let headerCell = MyHeaderCell.init(textCell: column.title) column.headerCell = headerCell } } 再現リポジトリです。実行するだけでクラッシュします。 クラッシュしない場合はテーブルのカラムを思いっきり左右にドラッグすると死にます。 https://github.com/omochi/nstableheadercell-bug (edited)2017-11-21 11:23:53.295486+0900 nstableheadercellbug[23493:18211887] Unknown Window class (null) in Interface Builder file, creating generic Window instead [Cat(0x00006100000490c0)::init] [MyHeaderCell(0x00006100000a0120)::init(textCell:)] [Cat(0x00006100000492d0)::init] [MyHeaderCell(0x00006100000a13e0)::init(textCell:)] [Cat(0x0000610000049360)::init] [MyHeaderCell(0x00006100000a14a0)::init(textCell:)] [MyHeaderCell(0x00006180000a6120)::deinit] [Cat(0x0000610000049360)::deinit] [MyHeaderCell(0x00006080000a55e0)::deinit]default column: 0x00006080000a0ea0 [MyHeaderCell(0x00006180000a23a0)::init(textCell:)] default column: 0x00006080000a1020 [MyHeaderCell(0x00006180000a21c0)::init(textCell:)] default column: 0x00006080000a11a0 [MyHeaderCell(0x00006180000a2820)::init(textCell:)] [MyHeaderCell(0x00006080000a20a0)::deinit] [MyHeaderCell(0x00006080000a2460)::deinit] [MyHeaderCell(0x00006100000a2b20)::deinit] [MyHeaderCell(0x00006100000a3360)::deinit] [MyHeaderCell(0x00006100000a3240)::deinit] [MyHeaderCell(0x00006080000a4140)::deinit]release を消したりしてみたのですが変わらず。何をしてるのかよくわからない。default column: 0x00006080000a61e0 [MyHeaderCell(0x000060c0000a0f60)::init(textCell:)] default column: 0x00006080000a6360 [MyHeaderCell(0x000060c0000a0fc0)::init(textCell:)] default column: 0x00006080000a64e0 [MyHeaderCell(0x000060c0000a1020)::init(textCell:)] [MyHeaderCell(0x000060c0000a1020)::copy] [MyHeaderCell(0x00006040000a5280)::deinit] [MyHeaderCell(0x000060c0000a1020)::copy] [MyHeaderCell(0x00006040000a5580)::deinit] [MyHeaderCell(0x000060c0000a1020)::copy] override func copy() -> Any { print("[MyHeaderCell(\(addr(self)))::copy]") return super.copy() } かもしれないですね。 override func copy(with zone: NSZone? = nil) -> Any { return MyHeaderCell.init(textCell: self.stringValue) } 落ちなくなった!!!!!!!!!!![self class] alloc] init]になっているんじゃないかと予想したけど、 ObjC版で init をオーバライドしても呼ばれないので違うなあ。 XcodeApplication *app = [SBApplication applicationWithBundleIdentifier: @"com.apple.dt.Xcode"]; NSString *className = app.className; // ちゃんと @"XcodeApplication" になってる SBElementArray<XcodeDocument *> * docs = app.documents; SBElementArray<XcodeWindow *> * windows = app.windows; XcodeDocument *doc = docs.firstObject; // nil XcodeWindow *window = windows.firstObject; // nil NSUInteger docC = app.documents.count; // 0 NSUInteger windowC = app.windows.count; // 0 NSString *name = app.name; // nil XcodeWorkspaceDocument *workspaceDocument = app.activeWorkspaceDocument; XcodeScheme *scheme = workspaceDocument.activeScheme; NSString *schemeName = scheme.name; // nil NSURL *url = workspaceDocument.file; // nil NSString *path = workspaceDocument.path; // nil SBElementArray<XcodeProject *> *projects = workspaceDocument.projects; XcodeProject *proj = projects.firstObject; // nil NSUInteger projC = projects.count; // 0 APIアクセスするたびにコンソールログには Error #17 (os/kern) invalid right attempting to add send right to port ( port:47563/0xb9cb rcv:1,send:0,d:0 limit:5). というエラーが吐かれるので何か問題があるのだろうけれど、その正体が掴めていません。 (edited)invalid right attempting to add send right to port なエラーが出ますが、documents, windowsの取得はできる様になりました。 (edited)SDP(1)で生成したヘッダをインポートして使おうとするとリンクエラーになってしまうので、 import ScriptingBridge @objc protocol XcodeApplication { @objc optional var documents: SBElementArray { get } @objc optional var windows: SBElementArray { get } } extension SBApplication: XcodeApplication {} guard let xcode: XcodeApplication = SBApplication(bundleIdentifier: "com.apple.dt.Xcode"), let docs = xcode.documents, let windows = xcode.windows else { return } みたいなのを書く必要があった。 (edited)XPC Service を新規作成 2. Bridging Headerに XXXProtocol.h を追加 3. ソースに以下を記述 let connection = NSXPCConnection(serviceName: "XPCのBundle Identifier") connection.remoteObjectInterface = NSXPCInterface(with: XcodeHelperProtocol.self) connection.resume() let xcode = connection.remoteObjectProxy as! XcodeHelperProtocol let semaphore = DispatchSemaphore(value: 0) xcode.upperCaseString("aaaa") { (str) in print(str) semaphore.signal() } _ = semaphore.wait(timeout: .now() + 10) XPC側を Wait for executable to be launched でRunさせたところ、プロセスのAttachすらできていないようでした。 なお、Cocoa App 側で同じことをやったところ、正常に連携できました。 Extensionだとうまくいかない要因が何かあるのでしょうが、nomuraさんのSwiftLintForXcodeでは連携できているのですよね… Projectの設定やinfo.plistの内容などをSwiftLintForXcodeからコピーしていっても一向に解決せず、とても不思議です。 何かコツがあれば、ご教授いただけたら幸いです。なお、Cocoa App 側で同じことをやったところ、正常に連携できました。 あ、僕のところとは違う理由かも。iOSDC ですけどiOSの...XcodeSchemeからXcodeBuildConfigurationまでたどり着く方法が見つからず、xcodebuild -workspace … -scheme … -showBuildSettingsの出力をパースするしかないと言う結論にたどり着きつつある….gestureRecognizers の要素数が、 Sierraだと2つなのがHighSierraだと1つに変わっていることがわかったのでNSButtonに設定しているのですが、 High Sierraにおいて押下時だけ変な見た目になって困っています。 (Mojaveでは問題なく表示されています) 調べた限りでは同じ問題が起こっている人は見つからなかったのですが、誰か何かご存じないでしょうか?rubyを2.7.2にする などで解決可能と書いてあるのですが, 他の解決方法で解決された方などいらっしゃればご教示いただきたいですmm 私の手元の環境は Catalina 10.15.7 command-line-tools 12.3 ruby 2.6.5 https://github.com/CocoaPods/CocoaPods/issues/10286xcode-select --install で commadlien tools を入れてexport DEVELOPER_DIR=/Library/Developer/CommandLineTools をしておいてください (edited)xcode-select -s /LibraryDeveloper/CommandLineTools でも可 (edited)Xcode12.3 Catalinaで動いてるから普通に問題なく動くのかなーって思い込んでました.