Xcode 默认启用文件访问

Xcode enable file access by default

自从我每次 运行 一个 Xcode 项目升级到 macOS Catalina 后,我都会得到这个对话框 window:

有没有办法默认启用访问或禁用此安全功能,这样我就不必在这个时候按下这个按钮?

您需要授予 XCode“完整磁盘访问权限”:

System Preferences->Security & Privacy->Full Disk Access->Add(+) [Applications-XCode] 

每次重新编译应用程序时都会重新提示您,因为 OS 每次都将其视为全新的二进制文件。如果您对二进制文件进行代码签名,OS 将识别不变的签名并将二进制文件视为“相同”(因此,请记住您的隐私选择)

来自Code Signing Tasks

Shipping and Updating Your Product The user’s system considers the new version of your product to be the same program as the previous version. For example, Keychain Services does not distinguish older and newer versions of your program as long as both are signed and the unique Identifier remains constant.

您需要使用 Apple ID 登录 Xcode(通过“偏好设置”>“帐户”)。免费的 Apple ID(相对于付费的开发者帐户)足以 signing code to run locally.

在您的项目设置中,在“签名和功能”选项卡下; select:

  • 自动管理签名
  • 您的个人团队
  • 签名证书:开发

也可以使用 codesign 在 Xcode 之外进行代码签名,但我不确定这如何与 Apple ID 一起使用。