macos: Clearing the quarantine extended attribute from downloaded applications

Apple doc: 在 Mac 上安全地打开 App

When I’m packaging an application for deployment, I normally download the latest version from the vendor. If it’s a drag-and-drop install, where the application is a self-contained bundle, it will get the com.apple.quarantine extended attribute associated with it.

The quarantine attribute is added by the OS so that it can ask for user confirmation the first time the downloaded program is run. Gatekeeper in Lion and Mountain Lion also uses the com.apple.quarantine attribute to determine if an application should be checked (and blocked if needed.)

To avoid issues with both unwanted messages and Gatekeeper, I normally clear this attribute as part of my packaging. Here’s how to check to see if your application has the com.apple.quarantine attribute associated with it:

  1. Open Terminal
  2. Run the following command:
xattr /path/to/MyApp.app

If the com.apple.quarantine attribute is associated with the application, you should see the following output:

computername:Applications username$ xattr /path/to/MyApp.app
com.apple.quarantine
computername:Applications username$

Note: Other attributes may also be listed, with com.apple.FinderInfo being a common one.

To remove the quarantine attribute, you would then run the following command:

sudo xattr -r -d com.apple.quarantine /path/to/MyApp.app

That will recursively remove the com.apple.quarantine attribute from the application. The -r option will allow the quarantine attribute of all files inside the application to be selected, while the -d option causes the given attribute name (and associated value) to be removed.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值