macos 如何打包 Mac OS 应用程序进行安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7014502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I package a Mac OS application for install?
提问by Colen
I know on windows there are a bunch of installer tools you can use to create an installer, but on Mac OS I've seen two ways to install apps:
我知道在 Windows 上有很多安装程序工具可以用来创建安装程序,但在 Mac OS 上我看到了两种安装应用程序的方法:
A DMG file which you download, double-click, then run an application inside - the application typically has you drag an icon to another icon (representing the Applications folder) to install the app
Another type of file which launches an apparently standard installer, which sometimes brings up a warning like "This installer may run a program to determine if you can go ahead with the install"
您下载的 DMG 文件,双击,然后在其中运行应用程序 - 该应用程序通常需要您将图标拖到另一个图标(代表应用程序文件夹)以安装该应用程序
另一种类型的文件会启动一个明显标准的安装程序,它有时会发出警告,例如“此安装程序可能会运行一个程序来确定您是否可以继续安装”
What's the "standard" way of packaging an app for install on Mac OS? Is one of the above the Apple-recommended way?
打包应用程序以在 Mac OS 上安装的“标准”方式是什么?以上是Apple推荐的方式之一吗?
Thanks.
谢谢。
采纳答案by SSteve
Apple is very clearly making the "standard" to be downloading a program from the App Store. This has the benefit of making application installation transparent to the normal user. And, believe it or not, normal people have a lot of trouble with the concept of installing a program. Of course that benefit comes with some costs, but this isn't the place for that debate–there are plenty of other places for that.
Apple 非常清楚地制定了从 App Store 下载程序的“标准”。这有利于使应用程序安装对普通用户透明。而且,不管你信不信,普通人在安装程序的概念上有很多麻烦。当然,这种好处会带来一些成本,但这不是辩论的地方——还有很多其他地方可以进行辩论。
Assuming you don't want to or can't go the App Store route, both PKG and DMG are common ways to distribute a program. Use a PKG if you need to install files aside from your application bundle (which should not be a common use case). In all other cases use a DMG that prompts the user to copy the application into the Applications folder. But a lot of your users will not understand that they need to do that (unless your target audience is solely knowledgeable computer users). They will run your application from the disk image. Ideally in this case, your program will detect that it is running from a disk image and offer to copy itself into the Applications folder.
假设您不想或不能走 App Store 路线,PKG 和 DMG 都是分发程序的常用方法。如果您需要安装除应用程序包之外的文件(这不应该是常见用例),请使用 PKG。在所有其他情况下,使用 DMG 提示用户将应用程序复制到 Applications 文件夹中。但是您的许多用户不会明白他们需要这样做(除非您的目标受众完全是知识渊博的计算机用户)。他们将从磁盘映像运行您的应用程序。理想情况下,在这种情况下,您的程序将检测到它正在从磁盘映像运行,并提供将其自身复制到 Applications 文件夹中。
回答by roland
Packagesworks well. If your deployment process must be kept simple, it is great.
包运行良好。如果您的部署过程必须保持简单,那就太好了。
The Quick build
consists of dragging your .app
onto Package
and it is done.
在Quick build
由拖动的.app
到Package
,它完成。
For advanced packaging, you can also provide a certificate.
对于高级封装,您还可以提供证书。
回答by Sacrilicious
We're discussing two things:
我们正在讨论两件事:
- first and most importantly, the standard method by which the bits of an executable get laid on the disk in a way that's accessible and properly registered by the system
- second, the mechanism for preparing the .app, as recommended by Apple
- 首先也是最重要的是,一种标准方法,通过该标准方法,可执行文件的位以系统可访问和正确注册的方式放置在磁盘上
- 二、苹果推荐的.app的准备机制
An older marketing page on Apple's sitesays it's recommended to create packages (so the Installer application can move the bits in place) with the PackageMaker application. Its usage is described here: mactech.com/articles/mactech/Vol.25/25.03/2503MacEnterprise-PackagingforSystemAdministrators/index.html.
Apple 网站上的一个较旧的营销页面表示,建议使用 PackageMaker 应用程序创建包(以便安装程序应用程序可以将位移动到位)。它的用法在这里描述:mactech.com/articles/mactech/Vol.25/25.03/2503MacEnterprise-PackagingforSystemAdministrators/index.html。
But as others have mentioned, the elephant in the room is the MacAppStore(MAS for short). Until it's debut, what was standard for large companies was their own custom scripts rolled into an older-style 'bundle' package or using an executable like the VISE installer. Smaller developers usually tried to make their app installable via drag-drop, distributed in zip archives or disk images(for simplicity's sake). The MAS is different: as of 10.7 it uses a package format (which debuted in 10.5) referred to as a flat package (really a xar archive, explanation here) which is transferred over http to a hidden folder, installs directly to Applications(after which the temporary folder it is downloaded to is deleted). It drops its receipt and a bill or materials file into /private/var/db, and is therefore audit-able by the built-in command line pkgutil tool, described here: mactech.com/articles/mactech/Vol.25/25.12/2512MacEnterprise-PackagesReceiptsandSnow/index.html
但正如其他人提到的,房间里的大象是 MacAppStore(简称 MAS)。在首次亮相之前,大公司的标准是将他们自己的自定义脚本卷入旧式“捆绑”包或使用 VISE 安装程序等可执行文件。较小的开发人员通常尝试通过拖放方式安装他们的应用程序,以 zip 存档或磁盘映像(为简单起见)分发。MAS 是不同的:从 10.7 开始,它使用称为平面包的包格式(在 10.5 中首次亮相)(实际上是一个 xar 存档,在此处解释)) 通过 http 传输到隐藏文件夹,直接安装到应用程序(之后它下载到的临时文件夹被删除)。它将其收据和账单或材料文件放入 /private/var/db,因此可以通过内置命令行 pkgutil 工具进行审计,如下所述:mactech.com/articles/mactech/Vol.25/25.12 /2512MacEnterprise-PackagesReceiptsandSnow/index.html
A benefit of using the flat package format is you can pull things over the network more safely and efficiently, but it isn't as easy to work with as bundle packages if you are testing and modifying the package regularly, or iterating to ensure scripts that perform actions or checks work well. Even when flat, putting the pkg in a archive or disk image is recommended for flexibility. More distribution tools expect DMG's than zip's, so there's that as well.
使用扁平包格式的一个好处是你可以更安全、更有效地通过网络拉取东西,但是如果你定期测试和修改包,或者迭代以确保脚本,它不像捆绑包那么容易执行操作或检查工作正常。即使是扁平的,为了灵活性,建议将 pkg 放在存档或磁盘映像中。更多的分发工具需要 DMG 而不是 zip,所以也是如此。
Besides what Apple recommends and what is standard, common practice, there's this article: https://www.afp548.com/2010/06/03/the-commandments-of-packaging-in-os-x/which discusses the why's and hows (although mainly for system administrators) of packaging for wider distribution. It is greatly recommended to get more of a feel of how and why things go wrong, and what to avoid.
除了 Apple 推荐的内容以及标准的常见做法之外,还有这篇文章:https: //www.afp548.com/2010/06/03/the-commandments-of-packaging-in-os-x/讨论了为什么以及如何(虽然主要针对系统管理员)打包以进行更广泛的分发。强烈建议您更多地了解出现问题的方式和原因,以及应该避免什么。
回答by ryotakatsuki
In OS X, many applications are just created as a Relocatable application bundles that the user just need to copy to the /Application folder (or any other location). In other cases, when you need to perform some operations over the machine (such as adding users or changing permissions) you can use a PKG installer (for example built using PackageMaker), which allows executing some pre and post install scripts and support some basic installation configuration, like selecting the installation drive.
在 OS X 中,许多应用程序只是作为可重定位应用程序包创建的,用户只需将其复制到 /Application 文件夹(或任何其他位置)。在其他情况下,当您需要在机器上执行某些操作(例如添加用户或更改权限)时,您可以使用 PKG 安装程序(例如使用PackageMaker构建),它允许执行一些安装前和安装后脚本并支持一些基本的安装配置,比如选择安装驱动。
Sometimes, as with complex server software, you need more flexibility, for example to show custom pages to the end user requesting information required to install your application, like the MySQL port and password or proxy information to download requirements on the fly (or simply to make it look fancier :)). For this cases there are other installer solutions like our BitRock InstallBuilder(disclaimer, I'm one of the developers). InstallBuilder also has the advantage of generating multiplatform installers using the same project with very little customization per platform.
有时,与复杂的服务器软件一样,您需要更大的灵活性,例如向最终用户显示自定义页面,请求安装应用程序所需的信息,如 MySQL 端口和密码或代理信息以即时下载要求(或简单地让它看起来更漂亮:))。对于这种情况,还有其他安装程序解决方案,例如我们的BitRock InstallBuilder(免责声明,我是开发人员之一)。InstallBuilder 还具有使用相同项目生成多平台安装程序的优势,每个平台的定制很少。