Xcode 15 中的新选项 ENABLE_USER_SCRIPT_SANDBOXING 是什么?

huangapple go评论87阅读模式
英文:

What is the new option ENABLE_USER_SCRIPT_SANDBOXING in Xcode 15?

问题

启用用户脚本沙盒是推荐的,以确保构建的正确性。这将启用 ENABLE_USER_SCRIPT_SANDBOXING 构建设置。

这会有什么影响?何时应该启用或禁用?如果我在构建阶段中设置了 SwiftGen 呢?

英文:

After downloading the Xcode 15 beta and running my project, I get a warning to update the project to recommended settings with

> Enable User Script Sandboxing
>
> Enabling user script sandboxing is recommended to ensure correctness of the build. This will enable the
> ENABLE_USER_SCRIPT_SANDBOXING build setting.

What are the implications? When should it enabled/disabled? What if I have i.e. SwiftGen set as a build phase?

答案1

得分: 11

如果它对您的项目造成问题,如果需要,您可以在 project.pbxproj 中将 ENABLE_USER_SCRIPT_SANDBOXING 更改为 NO。在 Xcode GUI 中,它是一个布尔选择列表或ASCII文本(取决于您选择的“打开方式”)。

我尝试了在我的项目上建议的 YES 设置,但我收到投诉,称我的情况(SwiftLint)试图读取一些非Swift文件。这些文件是 .git、.github、projectname.xcodeproj 和与字符串本地化相关的文件。显然,这4个文件都不是 .swift 文件,因此 SwiftLint 在打开这4个文件时过于热衷。而且当 SwiftLint 在沙箱中运行时,Xcode 几乎正确地导致构建失败。

令人惊讶的是,我还没有发现其他人抱怨这个问题。但我预计 SwiftLint 将在 Xcode 14 beta 阶段解决这个问题。

更改设置的位置以及我收到的错误消息。忽略6779号 - 可能是行号而不是错误代码

英文:

If it gives problems for your project, you can simply change ENABLE_USER_SCRIPT_SANDBOXING = YES back to NO in project.pbxproj if needed.
In the Xcode GUI it is a boolean pick list or ASCII text (depending what you select for "open as".

I tried the recommended YES setting on my own project, but I got complaints that my case (SwiftLint) was trying to read some non-Swift files. These were .git, .github, projectname.xcodeproj and a file related to string localisation. Clearly none of these 4 files were .swift files, so SwiftLint was over-zealous in opening these 4 files. And Xcode was more-or-less right to cause the build to fail when SwiftLint runs in a sandbox.

Surprisingly, I didn't find others complaining about this yet. But I expect SwiftLint will address this during the Xcode 14 beta phase.

Where to change the setting, and the error messages that I got. Ignore the 6779 number - probably a line number rather than an error code

答案2

得分: 1

> 用户脚本沙箱
> 设置名称:ENABLE_USER_SCRIPT_SANDBOXING
>
> 如果启用,构建系统将对用户脚本进行沙箱处理,以禁止未声明的输入/输出依赖项。

典型的错误如下:

沙箱:swiftlint(97252) 拒绝(1) 文件读取数据 /YourProject/.swiftlint.yml

可以通过以下方式解决:

输入文件
$(SRCROOT)/.swiftlint.yml

但对于整个文件列表,您可以执行以下操作:

输入文件列表
$(SRCROOT)/inputFiles.xcfilelist

您可以使用以下命令创建它:

find . \( -name "*.swift" -o -name ".swiftlint.yml" \) > inputFiles.xcfilelist

但这仍然是个问题,如何在每次编译时创建文件列表呢?

英文:

> User Script Sandboxing
> Setting name: ENABLE_USER_SCRIPT_SANDBOXING
>
> If enabled, the build system will sandbox user scripts to disallow undeclared input/output dependencies.

A typical error like this:

Sandbox: swiftlint(97252) deny(1) file-read-data /YourProject/.swiftlint.yml

is solved with

Input Files
$(SRCROOT)/.swiftlint.yml

But for a whole list of files you can do

Input File Lists
$(SRCROOT)/inputFiles.xcfilelist

which you can create with

find . \( -name "*.swift" -o -name ".swiftlint.yml" \) > inputFiles.xcfilelist

But this is still a problem, how can you create the list of files on every compilation?

huangapple
  • 本文由 发表于 2023年6月6日 15:01:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412148.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定