查找 App Group 的路径时返回 nil

Dav*_*vid 5 xcode swift

我已启用应用程序组并创建了一个名为“group.com.classData”的组 在此输入图像描述

我的代码如下所示:

let plistPath3 = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.classData")
print(plistPath3) //returns "nil"
Run Code Online (Sandbox Code Playgroud)

它返回零。为什么会发生这种情况?

bde*_*ham 3

我在开发共享扩展时遇到了这个错误。事实证明,虽然我已将应用程序组权利添加到app\xe2\x80\x99s目标,但我没有将 \xe2\x80\x99t 将其添加到扩展\xe2\x80\x99s目标。我需要从项目/目标下拉列表中选择扩展:

\n\n

Xcode 的屏幕截图,显示了包含项目和目标的下拉列表的位置。

\n\n

然后我单击“功能”选项卡并启用“应用程序组”。我为该应用程序创建的应用程序组已在列表中;我只需要选中它的复选框。当我再次运行该应用程序时,containerURL(forSecurityApplicationGroupIdentifier:)返回一个非零值。

\n