升级到 XCode 4.4 后运行 Mac 应用程序时权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11876726/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:11:22  来源:igfitidea点击:

Permission Denied when running Mac app after upgrading to XCode 4.4

xcodemacososx-mountain-lionxcode4.4

提问by Dennis

I had a working Mac application until I updated to XCode 4.4 and Mountain Lion. Now the application still compiles, but when I try to run it I get an error message.

在我更新到 XCode 4.4 和 Mountain Lion 之前,我有一个可以运行的 Mac 应用程序。现在应用程序仍然可以编译,但是当我尝试运行它时,我收到一条错误消息。

error: failed to launch '/Users/username/James/mac/Browser/trunk/Browser/DerivedData/Browser/Build/Products/Debug/Browser.app/Contents/MacOS/Browser' -- Permission denied*

Can anybody explain why I might be getting this?

谁能解释为什么我可能会得到这个?

采纳答案by jab

I found this on an iPhone 5 (iOS 6.0) newly set up for development. I had to manually launch the app on the phone, and it said "Are you sure you want to launch this app signed by this devloper?" Once I approved that, the "permission denied" went away and it now launches from Xcode.

我在新设置用于开发的 iPhone 5 (iOS 6.0) 上发现了这个。我不得不在手机上手动启动该应用程序,它说“您确定要启动此开发人员签名的应用程序吗?” 一旦我批准了,“权限被拒绝”就消失了,它现在从 Xcode 启动。

回答by Old McStopher

Unlock the Device

解锁设备

Try simply unlocking your device before running on it. I was stumped by this very same issue. Upon building and running with no changes to OS, environment, code, etc., I was receiving the error.

在运行之前尝试简单地解锁您的设备。我被同样的问题难住了。在未更改操作系统、环境、代码等的情况下构建和运行时,我收到了错误消息。

Similar questions have been asked hereand here, but were not helpful in this situation.

类似的问题在这里这里被问,但在这种情况下没有帮助。

回答by Peter Hosey

This is caused by an entitlement (and, presumably, having the wrong kind of certificate for it).

这是由权利引起的(并且可能是因为拥有错误的证书)。

  • If you have the sandbox enabled, and try to sign with a Developer ID certificate, your application will crash on launch (as of Lion—I haven't tried this on Mountain Lion).
  • If you have iCloud enabled, and try to sign with a Developer ID certificate, your application will not launch at all—in Xcode, you'll get the error message in the question, and in Finder, the application will launch ever so briefly and then get SIGKILLed.
  • 如果您启用了沙箱,并尝试使用开发人员 ID 证书进行签名,您的应用程序将在启动时崩溃(从 Lion 开始,我还没有在 Mountain Lion 上尝试过)。
  • 如果您启用了 iCloud,并尝试使用 Developer ID 证书进行签名,则您的应用程序根本不会启动——在 Xcode 中,您将收到问题中的错误消息,而在 Finder 中,应用程序将启动得如此短暂且然后被SIGKILLed。

Presumably, there is a right kind of certificate with which one can sign an app in order to be able to test with a sandbox and maybe even iCloud that you can obtain if you have a Mac Developer Program membership. A Developer ID certificate is not that kind of cert.

据推测,有一种正确的证书可以用来签署应用程序,以便能够使用沙箱甚至 iCloud 进行测试,如果您拥有 Mac 开发人员计划会员资格,则可以获得该证书。Developer ID 证书不是那种证书。

(That solves myproblem, anyway. Dennis, what kind of cert were you trying to sign with?)

(无论如何,这解决了我的问题。丹尼斯,你想用什么样的证书签名?)

回答by endy

Open the organizer and make sure you're mac is in developer mode.

打开管理器并确保您的 Mac 处于开发者模式。

Also check your gatekeeper settings.

还要检查您的网守设置。

回答by adamdehaven

The device is seeing the app as an "unauthorized app downloaded from the web" for lack of a better description. Go into Settings > Security & Privacy, and at the bottom, allow applications downloaded from Anywhere.

由于缺乏更好的描述,设备将该应用程序视为“从网络下载的未经授权的应用程序”。进入设置 > 安全和隐私,然后在底部允许从任何地方下载的应用程序。

回答by uliwitness

Throwing a few thoughts on the wall:

把一些想法扔在墙上:

  • Are you perhaps building on an external disk? Some drives get special permissions (like the "ignore permissions" checkbox), or maybe have ACLs set in a weird way. Tried building on internal startup disk?

  • Are you code signing? Have you tried just turning that off, to see if there's a bug in code signing or entitlements? Not the first time a new codesign tool has a bug.

  • Have you tried using xcode-select and updating any command line tools that are installed to make sure they all match the version of Xcode used?

  • Do you have any shell script build phases or the likes that might be editing the application after it's been signed, thus breaking the signature?

  • Have you checked if your hard disk is full or there's a (broken?) symlink somewhere in a path, or a volume name that has been unmounted?

  • 您可能是在外部磁盘上构建吗?某些驱动器获得特殊权限(如“忽略权限”复选框),或者可能以一种奇怪的方式设置了 ACL。尝试在内部启动磁盘上构建?

  • 你是代码签名吗?您是否尝试过将其关闭,以查看代码签名或权利中是否存在错误?新的协同设计工具出现错误已经不是第一次了。

  • 您是否尝试过使用 xcode-select 并更新已安装的任何命令行工具以确保它们都与所使用的 Xcode 版本相匹配?

  • 您是否有任何 shell 脚本构建阶段或类似程序可能在签名后编辑应用程序,从而破坏签名?

  • 您是否检查过您的硬盘是否已满或路径中某处是否有(损坏的?)符号链接,或已卸载的卷名?

回答by geekydevjoe

i am sure this is long been figured out, but I have been getting the Permission denied and it turned out I had to add my laptop to the provisioning profile. I had recently reimaged my machine and in doing so the provisioning profile was no longer valid for that machine. It worked fine until i enabled iCloud. That's when the permission denied started.

我相信这早就被发现了,但是我一直在拒绝权限,结果我不得不将我的笔记本电脑添加到配置文件中。我最近重新映像了我的机器,这样做时配置文件对那台机器不再有效。在我启用 iCloud 之前它运行良好。那是权限被拒绝的开始。

Check the organizer in XCODE, click on the devices tab and click on your machine on the left. Check to see that the UDID it shows is listed in the devices section in your mac developer portal.

检查 XCODE 中的管理器,单击设备选项卡,然后单击左侧的机器。检查它显示的 UDID 是否列在您的 mac 开发人员门户的设备部分中。

回答by rougeExciter

The short answer is when you get this error message, there is no valid development provisioning profile in the built application.

简短的回答是,当您收到此错误消息时,构建的应用程序中没有有效的开发配置文件。

That alone won't solve your problem! There are a number of common causes of this:

仅凭这一点并不能解决您的问题!造成这种情况的常见原因有很多:

  • You've moved to a new machine and haven't installed the provisioning profile in Xcode. Also see below
  • You've moved to a new machine and it's not in developer mode OR not added to the provisioning profile
  • 您已转移到一台新机器并且尚未在 Xcode 中安装配置文件。另见下文
  • 您已转移到一台新计算机,但它不在开发人员模式下或未添加到配置文件中

For both of these, let Xcode regenerate it, or do it yourself in the Member centre... You can validate the causes is something to do with your provisioning profile by running Console and filtering on taskgated where you can see which provisioning profile it is trying to use (it will pull the one embedded in the application first, then try to pull from any installed on the Mac).

对于这两种情况,让 Xcode 重新生成它,或者在会员中心自己做...您可以通过运行 Console 并在 taskgated 上过滤来验证原因是否与您的配置文件有关,您可以在其中查看它是哪个配置文件尝试使用(它会先拉出嵌入在应用程序中的那个,然后尝试从 Mac 上安装的任何一个中拉出)。

Make sure you check in your build settings that the right one is being used for Debug builds. Simple steps that normally resolve (XCode 5)

确保您检查构建设置,确保正确的设置用于调试构建。通常解决的简单步骤(XCode 5)

  1. Go to member centre and create a new development profile
  2. Select the app and certificate
  3. Validate that the machine you are using is in the list of machines to be included in the profile, tick the box
  4. Generate the certificate
  5. Download it, and drag it over the Xcode icon in the doc
  6. Go to the Build Settings tab in your target and set the provisioning profile to the one you've just downloaded

    • You haven't configured your iCloud/APN/GameCenter entitlements correctly.
  1. 转到会员中心并创建新的开发配置文件
  2. 选择应用程序和证书
  3. 验证您正在使用的机器在要包含在配置文件中的机器列表中,勾选框
  4. 生成证书
  5. 下载它,然后将它拖到文档中的 Xcode 图标上
  6. 转到目标中的 Build Settings 选项卡,并将配置文件设置为您刚刚下载的配置文件

    • 您没有正确配置您的 iCloud/APN/GameCenter 权利。