简体   繁体   English

如何在Mac上安装插件?

[英]How can I install a plugin on Mac?

I need to install a plugin on a Mac programmatically. 我需要以编程方式在Mac上安装插件。 I know a plugin can be installed by simply copying the .plugin file to the Internet Plug-ins folder, but since you need to enter a password to write to that folder, I have not been able to do it programmatically. 我知道可以通过简单地将.plugin文件复制到Internet Plug-ins文件夹来安装插件,但是由于您需要输入密码才能写入该文件夹,因此我无法以编程方式进行操作。 Is there any other way to install a plugin on a Mac? 还有其他方法可以在Mac上安装插件吗? Or is there a way to get around the password for the plugins folder? 还是有办法解决plugins文件夹的密码?

I would recommend using productbuild to create an Installer package. 我建议使用productbuild创建安装程序包。

Typically it's the standard way of installing something needing elevated privileges in OS X. It's also easy for the end user too; 通常,这是在OS X中安装需要提升特权的内容的标准方法。对于最终用户而言,这也很容易; Someone who downloads your installer package would simply double click on the icon, enter their administrator password and everything else would be taken care of by the installer. 下载您的安装程序包的人只需双击图标,输入管理员密码,其他所有内容都将由安装程序处理。

How It Works 这个怎么运作

Your plugin for example would be archived into into a .pkg as part of a payload that also contains parameters such as where it needs to be installed, and the appropriate permissions which it requires. 例如,您的插件将作为有效负载的一部分归档到.pkg中,该有效负载还包含诸如需要安装的位置以及所需的适当权限之类的参数。 It can even include installer plugins, execute additional scripts during the installation process, or contain instructions/readme. 它甚至可以包括安装程序插件,在安装过程中执行其他脚本或包含说明/自述文件。

Using the commandline version of productbuild can seem a little daunting at first, although once you create your first installer you should have a better understanding of the process. 刚开始使用productbuild的命令行版本似乎有些艰巨,尽管一旦创建了第一个安装程序,您应该对该过程有了更好的了解。 Fortunately there's a nice application built on top of the Apple productbuild tool called Packages , which makes productbuild easier to work with and is entirely free — which I highly recommend. 幸运的是,有一个不错的应用程序建立在Apple产品构建工具Packages的基础上 ,该工具使productbuild易于使用并且完全免费-我强烈建议这样做。

In short, this is just one way to get the job done — but most importantly very practical and widely used. 简而言之,这只是完成工作的一种方法,但最重要的是非常实用且被广泛使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM