xcode 在构建阶段“运行脚本”需要什么权限?

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

What permissions are required for "Run Script" during a build phase?

xcodebuildpermission-deniedrun-script

提问by Pterie Daktyl

In the "Run Script" build phase of my project, everything works if I type in the script into the text box for "run script" in build phases.

在我的项目的“运行脚本”构建阶段,如果我在构建阶段将脚本输入到“运行脚本”的文本框中,则一切正常。

But to make editing / diffing etc easier, I thought I would save the script as a file as part of my project, and just fill in the path in the text box instead:

但是为了使编辑/差异等更容易,我想我会将脚本另存为文件作为我项目的一部分,而只需在文本框中填写路径:

Eg: I paste the following path in the text box.

例如:我将以下路径粘贴到文本框中。

/Users/superman/Documents/Projects/SomeProject/scriptname.sh

But when I try to build this, I get a "Permission Denied" message.

但是当我尝试构建它时,我收到一条“权限被拒绝”消息。

What can I do to fix this? If I cut/paste the actual code, then it just "works". My user account is an administrator account. No one else uses my machine.

我能做些什么来解决这个问题?如果我剪切/粘贴实际代码,那么它就“有效”。我的用户帐户是管理员帐户。没有人使用我的机器。

回答by Scott

You can simplify your Xcode project file a little further and not require the "bin/sh " in front of the script name.

您可以进一步简化您的 Xcode 项目文件,而不需要在脚本名称前面添加“bin/sh”。

To avoid this, you need to turn on "execute" permissions for users (Xcode in this case) of the file.

为避免这种情况,您需要为文件的用户(在本例中为 Xcode)打开“执行”权限。

Steps

脚步

  • Go into terminal
  • Navigate to where your script is
  • run chmod 755 yourScriptName.sh
  • 进入终端
  • 导航到您的脚本所在的位置
  • chmod 755 yourScriptName.sh

回答by Android63

Put /bin/shin front of the path to the script name.

放在/bin/sh脚本名称的路径前面。

/bin/sh /Users/superman/Documents/Projects/SomeProject/scriptname.sh

回答by Bharat jain

Just use

只需使用

chmod u+x nameofscript.sh

Thats it .

就是这样 。

回答by Tunvir Rahman Tusher

Simple Steps:

简单步骤:

  1. Go to the <your_Script>.shvia cd <Your_Path_To_.sh_File>
  2. Run chmod +x <your_file>.sh
  1. 转到<your_Script>.sh通过cd <Your_Path_To_.sh_File>
  2. chmod +x <your_file>.sh

Thats it

就是这样