如何使扩展坞重新加载所有扩展坞磁贴插件?

发布于 2024-09-26 20:28:47 字数 161 浏览 0 评论 0原文

我正在制作一个使用停靠图块插件的应用程序。但是,当我重新编译我的扩展坞图块插件时,扩展坞仍然使用旧的插件,即使我 killall 扩展坞也是如此。解决此问题的唯一方法是重新启动我的 Mac,但我不想为我所做的每一个小代码更改都重新启动它。此外,码头图块插件的记录很少。谁能帮助我吗?

I am making an application which uses a dock tile plug-in. However, when I recompile my dock tile plugin, the dock still uses the old one, even when I killall the dock. The only way to fix this is by rebooting my Mac, but I don't want to reboot it for every little code change I make. Also, dock tile plugins are poorly documented. Can anyone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初见终念 2024-10-03 20:28:47

我使用 NSAlert 和 Accessability Inspector 发现一个名为 SystemUIServer 的进程负责停靠图块插件。只需执行以下操作即可:

$ killall SystemUIServer

这将重新启动 SystemUIServer 并重新加载停靠图块插件。

I found out using an NSAlert and Accessability Inspector that a process called SystemUIServer is responsible for dock tile plugins. Just do:

$ killall SystemUIServer

This will restart SystemUIServer and reload the dock tile plugins.

我是有多爱你 2024-10-03 20:28:47

您也可以在“活动监视器”中执行此操作。搜索“dock”并手动强制退出 com.apple.dock.extra。这是上面“键盘”选项的“鼠标”替代方案,并且不会造成那么多附带损害。

我建议在开发过程中,对于频繁的代码更改,您可以将上述命令包装在 Cocoa 任务中:

- (BOOL)killall:(NSString *)process {
    //Configure
    NSString *toolPath = @"usr/bin/killall";
    NSArray *arguments = [NSArray arrayWithObject:process];

    //Create
    NSTask *task = [[[NSTask alloc] init] autorelease];
    [task setLaunchPath:toolPath];
    [task setArguments:arguments];

    //Run
    [task launch];
    [task waitUntilExit];

    //Return success
    return ([task terminationStatus] == 0);
}

将其放入 NSApplication 的类别中,像这样执行:

NSLog(@"MyApp: killed UI Server: %d", [NSApp killall:@"SystemUIServer"]); //Comment out for release

OR(推荐)

NSLog(@"MyApp: killed Dock plugins: %d", [NSApp killall:@"com.apple.dock.extra"]); //Comment out for release

You can also do this in "Activity Monitor". Search for "dock" and force quit com.apple.dock.extra manually. This is the "mouse" alternative to the "keyboard" option above, and it doesn't do as much collateral damage.

I'd suggest that during development, for frequent code changes, you could wrap the above command in a Cocoa task:

- (BOOL)killall:(NSString *)process {
    //Configure
    NSString *toolPath = @"usr/bin/killall";
    NSArray *arguments = [NSArray arrayWithObject:process];

    //Create
    NSTask *task = [[[NSTask alloc] init] autorelease];
    [task setLaunchPath:toolPath];
    [task setArguments:arguments];

    //Run
    [task launch];
    [task waitUntilExit];

    //Return success
    return ([task terminationStatus] == 0);
}

Put this in a category on NSApplication, executed like so:

NSLog(@"MyApp: killed UI Server: %d", [NSApp killall:@"SystemUIServer"]); //Comment out for release

OR (recommended)

NSLog(@"MyApp: killed Dock plugins: %d", [NSApp killall:@"com.apple.dock.extra"]); //Comment out for release
青巷忧颜 2024-10-03 20:28:47

我最近一直在与这个问题作斗争,似乎杀死 Dock 进程或 SystemUIServer 进程本身都没有成功;我不得不杀了他们两个。

回到苹果关于这个主题的文档:

当您的应用程序从 Dock 中删除时,将使用 nil 参数调用 setDockTile: 方法。您的 setDockTile: 方法应释放 Dock Tile 对象,清理 Dock Tile 插件分配的所有资源,然后退出。

我发现,如果你从字面上理解苹果文档中的“并退出”,这些插件不会徘徊,卸载也很干净。不过,我觉得这样做有点肮脏(并已就此向苹果提交了反馈),因为我相信我的 exit(0) 也会导致其他应用程序的docktileplugins也被重新加载。 (我想必须诉诸于killall Dock/SystemUIServer 也会做同样的事情)

文档似乎也含糊不清...不知道为什么Apple 会希望你做良好的内存管理工作并在你做的下一件事是终止进程时释放对象。

    if(dockTile == nil) {
        NSLog(@"Docktile version %@ unloading", [[[NSBundle bundleForClass:[self class]] infoDictionary] valueForKey:@"CFBundleVersion"]);
        [_dockTile release], _dockTile = nil; // don't leak memory!
        exit(0); // ouch
    }

I have been battling with this recently, and it seems neither killing the Dock process or SystemUIServer process by themselves did the trick; I was having to kill them both.

Back to Apple's documentation on this subject:

When your application is removed from the Dock, the setDockTile: method is called with a nil parameter. Your setDockTile: method should release the Dock tile object, clean up any resources your Dock Tile plug-in allocated, and exit.

I've found that if you take the "and exit" from Apple's docs literally, these plugins don't linger around and unloading is clean. I feel a bit dirty doing this though (and have submitted feedback to Apple on this) because I believe my exit(0) is causing other apps' docktileplugins to be reloaded too. (I guess having to resort to killall Dock/SystemUIServer does the same)

The docs seem ambiguous too... Not sure why Apple would want you doing good memory management stuff and releasing objects when the next thing you do is kill the process.

    if(dockTile == nil) {
        NSLog(@"Docktile version %@ unloading", [[[NSBundle bundleForClass:[self class]] infoDictionary] valueForKey:@"CFBundleVersion"]);
        [_dockTile release], _dockTile = nil; // don't leak memory!
        exit(0); // ouch
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文